var egret = window.egret;var __reflect = (this && this.__reflect) || function (p, c, t) {
    p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;
};
var user_info = undefined;
var __extends = this && this.__extends || function __extends(t, e) { 
 function r() { 
 this.constructor = t;
}
for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]);
r.prototype = e.prototype, t.prototype = new r();
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [0, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var BaseTextField = (function (_super) {
    __extends(BaseTextField, _super);
    function BaseTextField() {
        var _this = _super.call(this) || this;
        _this.fontFamily = '微软雅黑';
        return _this;
    }
    Object.defineProperty(BaseTextField.prototype, "strWidth", {
        get: function () {
            this.calLabel.size = this.size;
            this.calLabel.bold = this.bold;
            this.calLabel.stroke = this.stroke;
            this.calLabel.italic = this.italic;
            this.calLabel.textFlow = this.textFlow;
            this.calLabel.maxChars = this.maxChars;
            this.calLabel.text = this.text;
            this.calLabel.height = this.height;
            this._strWidth = this.calLabel.width;
            return this._strWidth;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(BaseTextField.prototype, "calLabel", {
        get: function () {
            if (!this._calLabel) {
                var calLabel = new BaseTextField();
                this._calLabel = calLabel;
            }
            return this._calLabel;
        },
        enumerable: true,
        configurable: true
    });
    return BaseTextField;
}(egret.TextField));
__reflect(BaseTextField.prototype, "BaseTextField");
var BaseView = (function (_super) {
    __extends(BaseView, _super);
    function BaseView(w, h) {
        if (w === void 0) { w = GameData.stageW; }
        if (h === void 0) { h = GameData.stageH; }
        var _this = _super.call(this) || this;
        _this.width = w;
        _this.height = h;
        return _this;
    }
    return BaseView;
}(egret.DisplayObjectContainer));
__reflect(BaseView.prototype, "BaseView");
var PropAwardView = (function (_super) {
    __extends(PropAwardView, _super);
    function PropAwardView() {
        var _this = _super.call(this) || this;
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.getViews, _this);
        _this.touchEnabled = true;
        _this.addEventListener(egret.TouchEvent.TOUCH_TAP, _this.showPropAwards, _this);
        return _this;
    }
    PropAwardView.prototype.getViews = function () {
        return __awaiter(this, void 0, void 0, function () {
            var self, mc, proptext;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        self = this;
                        return [4 /*yield*/, ViewManager.mcManager.play('propaward', 'propaward', 'propaward')];
                    case 1:
                        mc = _a.sent();
                        mc.scaleX = 2;
                        mc.scaleY = 2;
                        mc.x = 0;
                        mc.y = 0;
                        mc.gotoAndPlay(1, -1);
                        self.addChild(mc);
                        proptext = new BaseTextField;
                        proptext.text = '奖励道具';
                        proptext.size = 22;
                        proptext.textColor = 0xefd78c;
                        proptext.stroke = 2;
                        proptext.strokeColor = 0x492a05;
                        proptext.bold = true;
                        proptext.y = this.height - proptext.height - 10;
                        proptext.x = this.width / 2 - proptext.width / 2;
                        this.addChild(proptext);
                        return [2 /*return*/];
                }
            });
        });
    };
    PropAwardView.prototype.showPropAwards = function () {
        Main.showRewardView();
    };
    return PropAwardView;
}(BaseView));
__reflect(PropAwardView.prototype, "PropAwardView");
var Main = (function (_super) {
    __extends(Main, _super);
    function Main() {
        var _this = _super.call(this) || this;
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.addedToStage, _this);
        return _this;
    }
    Main.prototype.addedToStage = function () {
        var vm = new ViewManager();
        Main._parent = this;
        this.onAddToStage();
        //游戏全局倒计时
        var timer = new egret.Timer(1000);
        timer.addEventListener(egret.TimerEvent.TIMER, this.update, Main._instance);
        timer.start();
    };
    Main.prototype.onAddToStage = function () {
        GameData.initData();
        this.runGame().catch(function (e) {
            console.log(e);
        });
    };
    Main.prototype.getUserInfo = function () {
        var _that = this;
        return new Promise(function (reslove, reject) {
            GameData.tvmid = utils.getQueryString('tvmid');
            GameData.token = utils.getQueryString("token");
            if (GameData.tvmid && GameData.token) {
                user_info = {
                    'nickname': 'debug_name'
                };
                utils.setCookie('tvmid', GameData.tvmid);
                utils.setCookie('apptoken', GameData.token);
                user_info['tvmid'] = GameData.tvmid;
                user_info['apptoken'] = GameData.token;
                reslove();
            }
            else {
                tvm.getUserInfo().then(function (data) {
                    user_info = data;
                    // utils.setCookie('tvmid', data.tvmid);
                    // utils.setCookie('apptoken', data.token);
                    var expire_time = utils.getCookie("login_apptoken_expire_time");
                    var login_apptoken = utils.getCookie("apptoken");
                    var curTime = new Date().getTime();
                    if (login_apptoken && expire_time != null && curTime < Number(expire_time)) {
                        GameData.tvmid = data.tvmid;
                        GameData.token = login_apptoken;
                        utils.setCookie('tvmid', GameData.tvmid);
                        utils.setCookie('apptoken', GameData.token);
                        user_info['tvmid'] = GameData.tvmid;
                        user_info['apptoken'] = GameData.token;
                        reslove();
                    }
                    else {
                        try {
                            _that.login(data).then(function () {
                                reslove();
                            });
                        }
                        catch (error) {
                            return false;
                        }
                    }
                }).catch(function () {
                    reject();
                    Main._parent.addChild(NoticeView.getInstance());
                    NoticeView.getInstance().noticeMsg = "用户身份验证失败，请尝试重新进入";
                    NoticeView.getInstance().callback = function () {
                        tvm.closeH5();
                    };
                });
            }
        });
    };
    //登录
    Main.prototype.login = function (data) {
        return __awaiter(this, void 0, void 0, function () {
            var pre_login_data, home_data, expire_time, e_1;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        _a.trys.push([0, 5, , 6]);
                        return [4 /*yield*/, this.pre_login(data)];
                    case 1:
                        pre_login_data = _a.sent();
                        if (!(pre_login_data['is_home'] == 1)) return [3 /*break*/, 3];
                        return [4 /*yield*/, this.safe_login(pre_login_data['apptoken'])];
                    case 2:
                        home_data = _a.sent();
                        expire_time = Number(home_data['create_time']) + Number(home_data['expire_time']);
                        if (expire_time.toString().length == 10) {
                            expire_time *= 1000;
                        }
                        utils.setCookie('tvmid', home_data["tvmid"]);
                        utils.setCookie('apptoken', home_data['apptoken']);
                        utils.setCookie('login_apptoken_expire_time', expire_time.toString());
                        GameData.tvmid = home_data["tvmid"];
                        GameData.token = home_data['apptoken'];
                        user_info['tvmid'] = GameData.tvmid;
                        user_info['apptoken'] = GameData.token;
                        GameData.is_tiyan = false;
                        return [3 /*break*/, 4];
                    case 3:
                        GameData.is_tiyan = true;
                        _a.label = 4;
                    case 4: return [3 /*break*/, 6];
                    case 5:
                        e_1 = _a.sent();
                        Main._parent.addChild(NoticeView.getInstance());
                        NoticeView.getInstance().noticeMsg = "用户身份验证失败，请尝试重新进入";
                        NoticeView.getInstance().callback = function () {
                            tvm.closeH5();
                        };
                        return [3 /*break*/, 6];
                    case 6: return [2 /*return*/];
                }
            });
        });
    };
    //预登录
    Main.prototype.pre_login = function (data) {
        var _that = this;
        return new Promise(function (resolve, reject) {
            var param = {
                tvmid: data.tvmid,
                apptoken: data.token
            };
            CurlUtil.curl(config.GoldHomeApi + "/login/app_pre_login", param).then(function (data) {
                if (data['status'] == "success") {
                    data = data['data'];
                    resolve(data);
                }
                else {
                    reject({ name: "pre_login", code: data['code'] });
                }
            }).catch(function () {
                reject({ name: "pre_login" });
            });
        });
    };
    //家园登录
    Main.prototype.safe_login = function (pre_apptoken) {
        var _that = this;
        return new Promise(function (resolve, reject) {
            var param = {
                pre_apptoken: pre_apptoken
            };
            CurlUtil.curl(config.GoldHomeApi + "/login/login", param).then(function (data) {
                if (data['status'] == "success") {
                    data = data['data'];
                    resolve(data);
                }
                else {
                    reject({ name: "safe_login", code: data['code'] });
                }
            }).catch(function () {
                reject({ name: "safe_login" });
            });
        });
    };
    Main.prototype.runGame = function () {
        return __awaiter(this, void 0, void 0, function () {
            var _this = this;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.loadResource()];
                    case 1:
                        _a.sent();
                        this.getWXInfo().then(function () {
                            _this.createGameScene();
                            Toast.init();
                        });
                        return [2 /*return*/];
                }
            });
        });
    };
    Main.prototype.getWXInfo = function () {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                return [2 /*return*/, new Promise(function (t, i) {
                        // <begin>
                        wx.login({
                            success: (res) => {
                                if (res.code) {
                                  let options = wx.getLaunchOptionsSync()
                                  if (options['query']['tvmid'] != undefined){
                                    wx.setStorageSync('tvmid', options['tvmid']);
                                  }
                                  // wx.setStorageSync('tvmid', 'wxh58490233603f7b352a44209f');
                                    CurlUtil.curl(config.GoldHomeApi + '/login/minigame_pre_login', {
                                        appid: config.APPID,
                                        code: res.code
                                    }).then((res) => {
                                        switch (res.code) {
                                            case 200:
                                                if (res.data.is_home == 1) {
                                                    //家园用户
                                                    CurlUtil.curl(config.GoldHomeApi + '/login/login', {
                                                        pre_apptoken: res.data.apptoken
                                                    }).then((res) => {
                                                        if (res.code == 200) {
                                                          wx.setStorageSync('apptoken', res.data.apptoken)
                                                          wx.setStorageSync('tvmid', res.data.tvmid)
                                                            t(res.data);
                                                        } else {
                                                            wx.showModal({
                                                                title: '提示',
                                                                content: '登录失败!',
                                                            });
                                                            i();
                                                        }
                                                    })
                                                } else {
                                                    //TODO 微信玩法
                                                    GameData.is_tiyan = true;
                                                    // 游客模式只记录预登陆apptoken 后面用
                                                    wx.setStorageSync('apptoken', res.data.apptoken);
                                                    t();
                                                }
                                                break;
                                            case 1003:
                                                //TODO 微信玩法
                                                break;
                                            default:
                                                wx.showModal({
                                                    title: '提示',
                                                    content: '接口异常！',
                                                })
                                                break;
                                        }
                                    })
                                }
                            }
                        })
                        // </begin>
                    })];
            });
        });
    };
    Main.prototype.loadResource = function () {
        return __awaiter(this, void 0, void 0, function () {
            var loadingView, e_2;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        _a.trys.push([0, 4, , 5]);
                        return [4 /*yield*/, RES.loadConfig(config.staticurl + "/resource/default.res.json", config.staticurl + "/resource/")];
                    case 1:
                        _a.sent();
                        // 加载排行榜资源
                        window.platform.openDataContext.postMessage({
                          command: "loadRes"
                        });
                        return [4 /*yield*/, RES.loadGroup("loading")];
                    case 2:
                        _a.sent();
                        loadingView = new LoadingUI();
                        Main._parent.addChild(loadingView);
                        return [4 /*yield*/, RES.loadGroup("preload", 0, loadingView)];
                    case 3:
                        _a.sent();
                        Main._parent.removeChild(loadingView);
                        return [3 /*break*/, 5];
                    case 4:
                        e_2 = _a.sent();
                        console.error(e_2);
                        return [3 /*break*/, 5];
                    case 5: return [2 /*return*/];
                }
            });
        });
    };
    Main.prototype.update = function () {
        if (ViewManager.initView) {
            ViewManager.initView.update();
        }
    };
    /**
     * 创建游戏场景
     * Create a game scene
     */
    Main.prototype.createGameScene = function () {
        GameData.initData();
        ViewManager.initView = new InitView();
        Main._parent.addChild(ViewManager.initView);
        // var jiFen = new JiFenView();
        // Main._parent.addChild(jiFen);
    };
    Main.showTop3View = function (data) {
        if (!ViewManager.top3View) {
            ViewManager.top3View = new TopThreeView(data);
        }
        Main._parent.addChild(ViewManager.top3View);
    };
    Main.removeTop3View = function () {
        if (Main._parent.contains(ViewManager.top3View)) {
            Main._parent.removeChild(ViewManager.top3View);
        }
    };
    Main.showResetView = function (type) {
        if (type === void 0) { type = 1; }
        return new Promise(function (reslove, reject) {
            if (!ViewManager.resetView) {
                ViewManager.resetView = new ResetAlertView();
            }
            if (!Main._parent.contains(ViewManager.resetView)) {
                ViewManager.resetView.setCallBack(reslove, reject);
                ViewManager.resetView.type = type;
                Main._parent.addChild(ViewManager.resetView);
            }
            else {
                reject();
            }
        });
    };
    Main.removeResetView = function () {
        if (Main._parent.contains(ViewManager.resetView)) {
            Main._parent.removeChild(ViewManager.resetView);
        }
    };
    Main.showRewardView = function () {
        if (!ViewManager.rewardView) {
            ViewManager.rewardView = new RewardView();
        }
        Main._parent.addChild(ViewManager.rewardView);
    };
    Main.removeRewardView = function () {
        if (Main._parent.contains(ViewManager.rewardView)) {
            Main._parent.removeChild(ViewManager.rewardView);
        }
    };
    Main.showJFView = function (endTime) {
        if (!ViewManager.jfView) {
            ViewManager.jfView = new JiFenRankView();
        }
        ViewManager.jfView.end_time = endTime;
        Main._parent.addChild(ViewManager.jfView);
    };
    Main.removeJFView = function () {
        if (Main._parent.contains(ViewManager.jfView)) {
            Main._parent.removeChild(ViewManager.jfView);
        }
    };
    Main.removeLastJFView = function () {
        if (Main._parent.contains(ViewManager.lastJFView)) {
            Main._parent.removeChild(ViewManager.lastJFView);
        }
    };
    Main.showLastJFView = function () {
        if (!ViewManager.lastJFView) {
            ViewManager.lastJFView = new LastJiFenRankView();
        }
        Main._parent.addChild(ViewManager.lastJFView);
    };
    Main.showHelpView = function () {
        if (!ViewManager.helpView) {
            ViewManager.helpView = new HelpAlertView();
        }
        // 1. 请求帮助接口
        if (GameData.rule == undefined || GameData.rule == '') {
            // 网络
            CurlUtil.curl(config.GoldHomeApi + "/dictionary/rules", {}).then(function (data) {
                if (data['status'] == 'success') {
                    data = data['data'];
                    var rule = data['chest_odd'];
                    if (rule != undefined && rule != '') {
                        GameData.rule = rule;
                        ViewManager.helpView.text = rule;
                        Main._parent.addChild(ViewManager.helpView);
                    }
                }
            }).catch(function (err) {
            });
        }
        else {
            // 直接弹
            ViewManager.helpView.text = GameData.rule;
            Main._parent.addChild(ViewManager.helpView);
        }
    };
    Main.showTooInfoView = function (data) {
        if (!ViewManager.toolInfoView) {
            ViewManager.toolInfoView = new ToolInfoView();
        }
        Main._parent.addChild(ViewManager.toolInfoView);
        ViewManager.toolInfoView.open(data);
    };
    Main.removeTooInfoView = function () {
        Main._parent.removeChild(ViewManager.toolInfoView);
    };
    Main.showNoEndView = function () {
        if (!ViewManager.noEndView) {
            ViewManager.noEndView = new NoEndView();
        }
        Main._parent.addChild(ViewManager.noEndView);
    };
    Main.removeNoEndView = function () {
        Main._parent.removeChild(ViewManager.noEndView);
    };
    Main._instance = null;
    return Main;
}(egret.DisplayObjectContainer));
__reflect(Main.prototype, "Main");
/**
 * Created by Dean on 2018-8-13.
 */
var ConstData;
(function (ConstData) {
    //暴击的区间
    ConstData.MAX_POINT_BEWTEEN = 10;
})(ConstData || (ConstData = {}));
/**
 * Created by Administrator on 2018/7/29.
 */
var GameData;
(function (GameData) {
    GameData.stageW = 750;
    GameData.stageH = 1334;
    GameData.rule = undefined; // 帮助文案
    GameData.colorArray = [
        0xEDDD08, 0x43DD3F, 0XFD72B1, 0X05E6FE, 0XFFFFFF, 0x38DDAB, 0x378EEE
    ];
    GameData.hasBeginning = true;
    GameData.tvmid = '';
    GameData.token = '';
    GameData.nickname = '你自己';
    GameData.personalRank = null;
    GameData.gangRank = null;
    GameData.resetSeed = 0;
    GameData.maxScore = 0;
    GameData.lefTime = 0;
    GameData.share_reset_count = 0; // 剩余分享重置机会次数
    GameData.video_reset_count = 0; // 剩余看视频重置机会次数
    function initData() {
        GameData.stageW = egret.MainContext.instance.stage.stageWidth;
        GameData.stageH = egret.MainContext.instance.stage.stageHeight;
        GameData.rotateSpeed = config.rotate_speed;
    }
    GameData.initData = initData;
    GameData.is_tiyan = false;
})(GameData || (GameData = {}));
/**
 * 简单的网络请求类
 */
var CurlUtil = (function () {
    function CurlUtil() {
    }
    CurlUtil.curl = function (url, data) {
        if (data === void 0) { data = {}; }
        return new Promise(function (reslove, reject) {
            var request = new egret.HttpRequest();
            request.open(url, egret.HttpMethod.POST);
            //设置响应头
            request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            request.responseType = egret.HttpResponseType.TEXT;
            //请求成功
            request.addEventListener(egret.Event.COMPLETE, function () {
                //对所有的接口返回进行检查是否有任务完成或者成就达成
                var result = JSON.parse(request.response);
                reslove(result);
            }, this);
            //请求失败
            request.addEventListener(egret.IOErrorEvent.IO_ERROR, function () {
                reject();
            }, this);
            if (GameData.is_tiyan) {
                try {
                    var apptoken = utils.getCookie('apptoken');
                    if (apptoken && !data.hasOwnProperty('pre_apptoken')) {
                        data.pre_apptoken = apptoken;
                    }
                }
                catch (e) { }
            }
            else {
                try {
                    var tvmid = utils.getCookie('tvmid');
                    if (tvmid && !data.hasOwnProperty('tvmid')) {
                        data.tvmid = tvmid;
                    }
                }
                catch (e) { }
                try {
                    var apptoken = utils.getCookie('apptoken');
                    if (apptoken && !data.hasOwnProperty('apptoken')) {
                        data.apptoken = apptoken;
                    }
                }
                catch (e) { }
            }
            var str = '';
            for (var k in data) {
                if (str != '') {
                    str += '&';
                }
                str += k;
                str += '=';
                str += data[k];
            }
            request.send(str);
        });
    };
    return CurlUtil;
}());
__reflect(CurlUtil.prototype, "CurlUtil");
var Key = (function () {
    function Key() {
    }
    Key.k1 = function (str) {
        var a = str.split(' ');
        var s = '';
        for (var i = 0; i < a.length; i += 2) {
            s += a[i];
        }
        return s;
    };
    Key.k2 = function (str) {
        var a = str.split(' ');
        var s = '';
        for (var i = 1; i < a.length; i += 2) {
            s += a[i];
        }
        return s;
    };
    return Key;
}());
__reflect(Key.prototype, "Key");
/*
 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
 * Digest Algorithm, as defined in RFC 1321.
 * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
 * Distributed under the BSD License
 * See http://pajhome.org.uk/crypt/md5 for more info.
 */
/*
 * Configurable variables. You may need to tweak these to be compatible with
 * the server-side, but the defaults work in most cases.
 */
var md5 = (function () {
    function md5() {
        this.hexcase = 0;
        /* hex output format. 0 - lowercase; 1 - uppercase        */
        this.b64pad = "";
    }
    /* base-64 pad character. "=" for strict RFC compliance   */
    /*
     * These are the privates you'll usually want to call
     * They take string arguments and return either hex or base-64 encoded strings
     */
    md5.prototype.hex_md5 = function (s) {
        return this.rstr2hex(this.rstr_md5(this.str2rstr_utf8(s)));
    };
    md5.prototype.b64_md5 = function (s) {
        return this.rstr2b64(this.rstr_md5(this.str2rstr_utf8(s)));
    };
    md5.prototype.any_md5 = function (s, e) {
        return this.rstr2any(this.rstr_md5(this.str2rstr_utf8(s)), e);
    };
    md5.prototype.hex_hmac_md5 = function (k, d) {
        return this.rstr2hex(this.rstr_hmac_md5(this.str2rstr_utf8(k), this.str2rstr_utf8(d)));
    };
    md5.prototype.b64_hmac_md5 = function (k, d) {
        return this.rstr2b64(this.rstr_hmac_md5(this.str2rstr_utf8(k), this.str2rstr_utf8(d)));
    };
    md5.prototype.any_hmac_md5 = function (k, d, e) {
        return this.rstr2any(this.rstr_hmac_md5(this.str2rstr_utf8(k), this.str2rstr_utf8(d)), e);
    };
    /*
     * Perform a simple self-test to see if the VM is working
     */
    md5.prototype.md5_vm_test = function () {
        return this.hex_md5("abc").toLowerCase() == "900150983cd24fb0d6963f7d28e17f72";
    };
    /*
     * Calculate the MD5 of a raw string
     */
    md5.prototype.rstr_md5 = function (s) {
        return this.binl2rstr(this.binl_md5(this.rstr2binl(s), s.length * 8));
    };
    /*
     * Calculate the HMAC-MD5, of a key and some data (raw strings)
     */
    md5.prototype.rstr_hmac_md5 = function (key, data) {
        var bkey = this.rstr2binl(key);
        if (bkey.length > 16)
            bkey = this.binl_md5(bkey, key.length * 8);
        var ipad = Array(16), opad = Array(16);
        for (var i = 0; i < 16; i++) {
            ipad[i] = bkey[i] ^ 0x36363636;
            opad[i] = bkey[i] ^ 0x5C5C5C5C;
        }
        var hash = this.binl_md5(ipad.concat(this.rstr2binl(data)), 512 + data.length * 8);
        return this.binl2rstr(this.binl_md5(opad.concat(hash), 512 + 128));
    };
    /*
     * Convert a raw string to a hex string
     */
    md5.prototype.rstr2hex = function (input) {
        try {
            this.hexcase;
        }
        catch (e) {
            this.hexcase = 0;
        }
        var hex_tab = this.hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
        var output = "";
        var x;
        for (var i = 0; i < input.length; i++) {
            x = input.charCodeAt(i);
            output += hex_tab.charAt((x >>> 4) & 0x0F)
                + hex_tab.charAt(x & 0x0F);
        }
        return output;
    };
    /*
     * Convert a raw string to a base-64 string
     */
    md5.prototype.rstr2b64 = function (input) {
        try {
            this.b64pad;
        }
        catch (e) {
            this.b64pad = '';
        }
        var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
        var output = "";
        var len = input.length;
        for (var i = 0; i < len; i += 3) {
            var triplet = (input.charCodeAt(i) << 16)
                | (i + 1 < len ? input.charCodeAt(i + 1) << 8 : 0)
                | (i + 2 < len ? input.charCodeAt(i + 2) : 0);
            for (var j = 0; j < 4; j++) {
                if (i * 8 + j * 6 > input.length * 8)
                    output += this.b64pad;
                else
                    output += tab.charAt((triplet >>> 6 * (3 - j)) & 0x3F);
            }
        }
        return output;
    };
    /*
     * Convert a raw string to an arbitrary string encoding
     */
    md5.prototype.rstr2any = function (input, encoding) {
        var divisor = encoding.length;
        var i, j, q, x, quotient;
        /* Convert to an array of 16-bit big-endian values, forming the dividend */
        var dividend = Array(Math.ceil(input.length / 2));
        for (i = 0; i < dividend.length; i++) {
            dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1);
        }
        /*
         * Repeatedly perform a long division. The binary array forms the dividend,
         * the length of the encoding is the divisor. Once computed, the quotient
         * forms the dividend for the next step. All remainders are stored for later
         * use.
         */
        var full_length = Math.ceil(input.length * 8 /
            (Math.log(encoding.length) / Math.log(2)));
        var remainders = Array(full_length);
        for (j = 0; j < full_length; j++) {
            quotient = Array();
            x = 0;
            for (i = 0; i < dividend.length; i++) {
                x = (x << 16) + dividend[i];
                q = Math.floor(x / divisor);
                x -= q * divisor;
                if (quotient.length > 0 || q > 0)
                    quotient[quotient.length] = q;
            }
            remainders[j] = x;
            dividend = quotient;
        }
        /* Convert the remainders to the output string */
        var output = "";
        for (i = remainders.length - 1; i >= 0; i--)
            output += encoding.charAt(remainders[i]);
        return output;
    };
    /*
     * Encode a string as utf-8.
     * For efficiency, this assumes the input is valid utf-16.
     */
    md5.prototype.str2rstr_utf8 = function (input) {
        var output = "";
        var i = -1;
        var x, y;
        while (++i < input.length) {
            /* Decode utf-16 surrogate pairs */
            x = input.charCodeAt(i);
            y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
            if (0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF) {
                x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF);
                i++;
            }
            /* Encode output as utf-8 */
            if (x <= 0x7F)
                output += String.fromCharCode(x);
            else if (x <= 0x7FF)
                output += String.fromCharCode(0xC0 | ((x >>> 6) & 0x1F), 0x80 | (x & 0x3F));
            else if (x <= 0xFFFF)
                output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F), 0x80 | ((x >>> 6) & 0x3F), 0x80 | (x & 0x3F));
            else if (x <= 0x1FFFFF)
                output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07), 0x80 | ((x >>> 12) & 0x3F), 0x80 | ((x >>> 6) & 0x3F), 0x80 | (x & 0x3F));
        }
        return output;
    };
    /*
     * Encode a string as utf-16
     */
    md5.prototype.str2rstr_utf16le = function (input) {
        var output = "";
        for (var i = 0; i < input.length; i++)
            output += String.fromCharCode(input.charCodeAt(i) & 0xFF, (input.charCodeAt(i) >>> 8) & 0xFF);
        return output;
    };
    md5.prototype.str2rstr_utf16be = function (input) {
        var output = "";
        for (var i = 0; i < input.length; i++)
            output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF, input.charCodeAt(i) & 0xFF);
        return output;
    };
    /*
     * Convert a raw string to an array of little-endian words
     * Characters >255 have their high-byte silently ignored.
     */
    md5.prototype.rstr2binl = function (input) {
        var output = Array(input.length >> 2);
        for (var i = 0; i < output.length; i++)
            output[i] = 0;
        for (var i = 0; i < input.length * 8; i += 8)
            output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (i % 32);
        return output;
    };
    /*
     * Convert an array of little-endian words to a string
     */
    md5.prototype.binl2rstr = function (input) {
        var output = "";
        for (var i = 0; i < input.length * 32; i += 8)
            output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF);
        return output;
    };
    /*
     * Calculate the MD5 of an array of little-endian words, and a bit length.
     */
    md5.prototype.binl_md5 = function (x, len) {
        /* append padding */
        x[len >> 5] |= 0x80 << ((len) % 32);
        x[(((len + 64) >>> 9) << 4) + 14] = len;
        var a = 1732584193;
        var b = -271733879;
        var c = -1732584194;
        var d = 271733878;
        for (var i = 0; i < x.length; i += 16) {
            var olda = a;
            var oldb = b;
            var oldc = c;
            var oldd = d;
            a = this.md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
            d = this.md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
            c = this.md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
            b = this.md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
            a = this.md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
            d = this.md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
            c = this.md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
            b = this.md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
            a = this.md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
            d = this.md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
            c = this.md5_ff(c, d, a, b, x[i + 10], 17, -42063);
            b = this.md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
            a = this.md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
            d = this.md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
            c = this.md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
            b = this.md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
            a = this.md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
            d = this.md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
            c = this.md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
            b = this.md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
            a = this.md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
            d = this.md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
            c = this.md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
            b = this.md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
            a = this.md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
            d = this.md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
            c = this.md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
            b = this.md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
            a = this.md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
            d = this.md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
            c = this.md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
            b = this.md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
            a = this.md5_hh(a, b, c, d, x[i + 5], 4, -378558);
            d = this.md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
            c = this.md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
            b = this.md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
            a = this.md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
            d = this.md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
            c = this.md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
            b = this.md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
            a = this.md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
            d = this.md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
            c = this.md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
            b = this.md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
            a = this.md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
            d = this.md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
            c = this.md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
            b = this.md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
            a = this.md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
            d = this.md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
            c = this.md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
            b = this.md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
            a = this.md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
            d = this.md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
            c = this.md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
            b = this.md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
            a = this.md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
            d = this.md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
            c = this.md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
            b = this.md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
            a = this.md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
            d = this.md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
            c = this.md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
            b = this.md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
            a = this.safe_add(a, olda);
            b = this.safe_add(b, oldb);
            c = this.safe_add(c, oldc);
            d = this.safe_add(d, oldd);
        }
        return [a, b, c, d];
    };
    /*
     * These privates implement the four basic operations the algorithm uses.
     */
    md5.prototype.md5_cmn = function (q, a, b, x, s, t) {
        return this.safe_add(this.bit_rol(this.safe_add(this.safe_add(a, q), this.safe_add(x, t)), s), b);
    };
    md5.prototype.md5_ff = function (a, b, c, d, x, s, t) {
        return this.md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
    };
    md5.prototype.md5_gg = function (a, b, c, d, x, s, t) {
        return this.md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
    };
    md5.prototype.md5_hh = function (a, b, c, d, x, s, t) {
        return this.md5_cmn(b ^ c ^ d, a, b, x, s, t);
    };
    md5.prototype.md5_ii = function (a, b, c, d, x, s, t) {
        return this.md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
    };
    /*
     * Add integers, wrapping at 2^32. This uses 16-bit operations internally
     * to work around bugs in some JS interpreters.
     */
    md5.prototype.safe_add = function (x, y) {
        var lsw = (x & 0xFFFF) + (y & 0xFFFF);
        var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
        return (msw << 16) | (lsw & 0xFFFF);
    };
    /*
     * Bitwise rotate a 32-bit number to the left.
     */
    md5.prototype.bit_rol = function (num, cnt) {
        return (num << cnt) | (num >>> (32 - cnt));
    };
    return md5;
}());
__reflect(md5.prototype, "md5");
var MovieClipManager = (function () {
    function MovieClipManager() {
        this.pngObj = {}; // 图片文件对象池
        this.jsonObj = {}; // json文件对象池
        this.roleObj = {}; // movieClip对象池
    }
    MovieClipManager.prototype.clear = function (imgName, jsonName, actionName) {
        if (!imgName) {
            this.pngObj = {};
        }
        else {
            if (this.pngObj[imgName])
                this.pngObj[imgName] = null;
        }
        if (!jsonName) {
            this.jsonObj = {};
        }
        else {
            if (this.jsonObj[jsonName])
                this.jsonObj[jsonName] = null;
        }
        if (!actionName) {
            this.roleObj = {};
        }
        else {
            var role = this.roleObj[actionName] ? this.roleObj[actionName] : null;
            if (role) {
                if (role.parent)
                    role.parent.removeChild(role);
                role = null;
            }
        }
    };
    /**
     * pngName: 图片名
     * jsonName: json配置项名称
     * actionName: action名
     * callback: 获取对象后的回调
     */
    MovieClipManager.prototype.play = function (pngName, jsonName, actionName) {
        return __awaiter(this, void 0, void 0, function () {
            var mcData, mcTexture, mcDataFactory, role, role1;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        if (!(this.checkArr(pngName, this.pngObj) && this.checkArr(jsonName, this.jsonObj))) return [3 /*break*/, 1];
                        // movieClip对象池中是否存在对应的action 有 就直接返回 没有 就创建
                        if (this.checkArr(actionName, this.roleObj)) {
                            return [2 /*return*/, this.roleObj[actionName]];
                        }
                        ;
                        mcData = this.jsonObj[jsonName];
                        mcTexture = this.pngObj[pngName];
                        mcDataFactory = new egret.MovieClipDataFactory(mcData, mcTexture);
                        role = new egret.MovieClip(mcDataFactory.generateMovieClipData(actionName));
                        return [2 /*return*/, role];
                    case 1: return [4 /*yield*/, this.loadSource(pngName, jsonName, actionName)];
                    case 2:
                        role1 = _a.sent();
                        return [2 /*return*/, role1];
                }
            });
        });
    };
    MovieClipManager.prototype.loadSource = function (pngName, jsonName, actionName) {
        return __awaiter(this, void 0, void 0, function () {
            var _this = this;
            var self;
            return __generator(this, function (_a) {
                self = this;
                return [2 /*return*/, new Promise(function (reslove, reject) {
                        var mcTexture, mcData;
                        var check = function () {
                            if (mcTexture && mcData) {
                                // 两个资源齐了 放进对象池 并创建对象
                                self.jsonObj[jsonName] = mcData;
                                self.pngObj[pngName] = mcTexture;
                                var mcDataFactory = new egret.MovieClipDataFactory(mcData, mcTexture);
                                var role = new egret.MovieClip(mcDataFactory.generateMovieClipData(actionName));
                                self.roleObj[actionName] = role;
                                reslove(role);
                            }
                        };
                        if (_this.checkArr(pngName, _this.pngObj)) {
                            mcTexture = self.pngObj[pngName];
                        }
                        else {
                            // var loader = new egret.URLLoader();
                            // loader.addEventListener(egret.Event.COMPLETE, function loadOver(e) {
                            //     var loader = e.currentTarget;
                            //     mcTexture = loader.data;
                            //     check();
                            // }, this);
                            // loader.dataFormat = egret.URLLoaderDataFormat.TEXTURE;
                            // var request = new egret.URLRequest(config.staticurl + "/resource/assets/mc/" + pngName + '.png');
                            // loader.load(request);
                            mcTexture = RES.getRes(pngName + '_png');
                            check();
                        }
                        if (_this.checkArr(jsonName, _this.jsonObj)) {
                            mcData = self.jsonObj[jsonName];
                        }
                        else {
                            // var loader = new egret.URLLoader();
                            // loader.addEventListener(egret.Event.COMPLETE, function loadOver(e) {
                            //     var loader = e.currentTarget;
                            //     mcData = JSON.parse(loader.data);
                            //     check();
                            // }, this);
                            // loader.dataFormat = egret.URLLoaderDataFormat.TEXT;
                            // var request = new egret.URLRequest(config.staticurl + "/resource/assets/mc/" + jsonName + '.json');
                            // loader.load(request);
                            mcData = RES.getRes(jsonName + '_json');
                            check();
                        }
                    })];
            });
        });
    };
    // 检查数组中是否存在某个key
    MovieClipManager.prototype.checkArr = function (name, obj) {
        // 检测两个对象池
        for (var key in obj) {
            if (obj.hasOwnProperty(key)) {
                var element = obj[key];
                if (key == name && element != undefined && element != null)
                    return true;
            }
        }
        return false;
    };
    return MovieClipManager;
}());
__reflect(MovieClipManager.prototype, "MovieClipManager");
var TableView;
(function (TableView_1) {
    var Direction;
    (function (Direction) {
        Direction[Direction["noChanged"] = 1] = "noChanged";
        Direction[Direction["alwaysTop"] = 2] = "alwaysTop";
        Direction[Direction["alwaysBottom"] = 3] = "alwaysBottom";
    })(Direction = TableView_1.Direction || (TableView_1.Direction = {}));
    var RefreshState;
    (function (RefreshState) {
        RefreshState[RefreshState["normal"] = 1] = "normal";
        RefreshState[RefreshState["willdownRefresh"] = 2] = "willdownRefresh";
        RefreshState[RefreshState["startdownRefresh"] = 3] = "startdownRefresh";
        RefreshState[RefreshState["downRefreshing"] = 4] = "downRefreshing";
        RefreshState[RefreshState["willupLoad"] = 5] = "willupLoad";
        RefreshState[RefreshState["startupLoad"] = 6] = "startupLoad";
        RefreshState[RefreshState["upLoading"] = 7] = "upLoading";
    })(RefreshState || (RefreshState = {}));
    var TableView = (function (_super) {
        __extends(TableView, _super);
        function TableView() {
            var _this = _super.call(this) || this;
            _this.direction = Direction.noChanged; // 刷新数据源时，tableView的位置
            _this._currentRefreshState = RefreshState.normal;
            _this._tempBottomV = 0;
            _this.loading = false;
            _this.scrollDirection = 0; // 滑动方向 正数为上拉 负数为下拉
            _this.lastPosition = 0; // 记录上次的滚动点 用于判断方向
            // 1.不管数据多少 只要有数据 都可以滚动
            _this.scrollPolicyV = eui.ScrollPolicy.ON;
            _this.touchEnabled = true;
            // 2. 初始化配置项
            _this._config = {
                movieClipJsonName: '',
                movieClipImgName: '',
                movieClipActionName: 'juhua',
                willUpLoadTitle: '',
                canUploadTitle: '',
                upLoadingTitle: '',
                willDownRefreshTitle: '',
                downRefreshTitle: '',
                canRefreshTitle: '',
                downRegreshedTitle: '',
                noMoreDataTitle: '',
                topInstance: 40,
                bottomInstance: 40 // 上拉时的界限
            };
            // 2.添加到父视图监听
            _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.viewDidLoad, _this);
            return _this;
        }
        TableView.prototype.viewDidLoad = function (event) {
            // 1. 是否需要监听滚动 以防万一 如果没必要就删除监听
            if (this.refreshAction || this.loadAction) {
                if (!this.hasEventListener(egret.Event.CHANGE)) {
                    this.addEventListener(egret.Event.CHANGE, this.scrollIsScrolling, this);
                    this.addEventListener(eui.UIEvent.CHANGE_END, this.scrollDidEnd, this);
                }
            }
            else {
                if (this.hasEventListener(egret.Event.CHANGE)) {
                    this.removeEventListener(egret.Event.CHANGE, this.scrollIsScrolling, this);
                }
                if (this.hasEventListener(eui.UIEvent.CHANGE_END)) {
                    this.removeEventListener(eui.UIEvent.CHANGE_END, this.scrollDidEnd, this);
                }
            }
        };
        /*********************************************** public **********************************************************/
        TableView.prototype.addItem = function (value) {
            this._collection.addItem(value);
        };
        TableView.prototype.addItemAt = function (value, index) {
            this._collection.addItemAt(value, index);
        };
        TableView.prototype.removeItemAt = function (index) {
            this._collection.removeItemAt(index);
        };
        TableView.prototype.removeAll = function () {
            this._collection.removeAll();
        };
        TableView.prototype.reset = function () {
            this._isRefreshing = false;
            this._isUploading = false;
            this.endRefreshing = true;
            this.endLoading = true;
            this._currentRefreshState = RefreshState.normal;
            this.loadEnd = false;
            this.removeFooterView();
            this.removeHeaderView();
        };
        /*********************************************** scroller **********************************************************/
        TableView.prototype.scrollIsScrolling = function (event) {
            if (this._isUploading || this._isRefreshing) {
                return;
            }
            // 判断当前滑动的方向 正数为上拉 负数为下拉
            this.scrollDirection = (this.viewport.scrollV - this.lastPosition);
            if (this.scrollDirection == 0)
                return; // 滚动方向等于0就直接忽略 很讨厌
            this.lastPosition = this.viewport.scrollV;
            if (this.viewport.contentHeight >= this.height) {
                this.higherScrollingAction();
            }
            else {
                this.lowerScrollingAction();
            }
        };
        // 滚动监听事件 当内容大于屏幕时
        TableView.prototype.higherScrollingAction = function () {
            // 上拉
            if (this.scrollDirection > 0) {
                // 也有可能是下拉的回弹
                if (this.viewport.scrollV < 0) {
                    if (!this.refreshAction)
                        return;
                    if (this.viewport.scrollV < -this.config['topInstance']) {
                        if (this._currentRefreshState != RefreshState.startdownRefresh) {
                            this._currentRefreshState = RefreshState.startdownRefresh;
                            this.startRefreshAction();
                        }
                    }
                }
                else {
                    // 上拉事件
                    if (!this.loadAction)
                        return;
                    if (this.loadEnd)
                        return;
                    this._tempBottomV = this.viewport.scrollV + this.height - this.viewport.contentHeight;
                    if (this._tempBottomV < 0)
                        return;
                    if (this._tempBottomV < this.config['bottomInstance']) {
                        if (this._currentRefreshState != RefreshState.willupLoad) {
                            this._currentRefreshState = RefreshState.willupLoad;
                            // 准备上拉加载时 要干啥？
                            this.willuploadAction();
                        }
                    }
                    else {
                        if (this._currentRefreshState != RefreshState.upLoading) {
                            this._currentRefreshState = RefreshState.upLoading;
                            // 上拉加载时 要干啥？
                            this.upLoadingAction();
                        }
                    }
                }
            }
            else {
                this._tempBottomV = this.viewport.scrollV + this.height - this.viewport.contentHeight;
                if (this._tempBottomV > 0) {
                    if (!this.loadAction)
                        return;
                    if (this.loadEnd)
                        return;
                    if (this._tempBottomV > this.config['bottomInstance']) {
                        if (this._currentRefreshState != RefreshState.startupLoad) {
                            this._currentRefreshState = RefreshState.startupLoad;
                            this.startUpLoadAction();
                        }
                    }
                }
                else {
                    // 下拉事件
                    // 如果action不存在 直接啥都不干
                    if (!this.refreshAction)
                        return;
                    // 大于0 说明是正常的滚动 直接忽略
                    if (this.viewport.scrollV > 0)
                        return;
                    // 超出一定范围 触发下拉加载事件
                    if (this.viewport.scrollV < -this.config['topInstance']) {
                        // 开始下拉刷新
                        if (this._currentRefreshState != RefreshState.downRefreshing) {
                            this._currentRefreshState = RefreshState.downRefreshing;
                            // 下拉刷新时 要干啥？
                            this.refreshingAction();
                        }
                    }
                    else {
                        // 准备下拉刷新 在下拉 但是还没到达指定位置
                        if (this._currentRefreshState != RefreshState.willdownRefresh) {
                            this._currentRefreshState = RefreshState.willdownRefresh;
                            // 即将下拉刷新时 要干啥
                            this.willRefreshAction();
                        }
                    }
                }
            }
        };
        // 滚动监听事件 当内容小于屏幕时
        TableView.prototype.lowerScrollingAction = function () {
            // 上拉
            if (this.scrollDirection > 0) {
                if (this.viewport.scrollV < 0) {
                    if (!this.refreshAction)
                        return;
                    if (this.viewport.scrollV <= -this.config['topInstance']) {
                        if (this._currentRefreshState != RefreshState.startdownRefresh) {
                            this._currentRefreshState = RefreshState.startdownRefresh;
                            this.startRefreshAction();
                        }
                    }
                }
                else {
                    if (!this.loadAction)
                        return;
                    if (this.loadEnd)
                        return;
                    if (this.viewport.scrollV < this.config['bottomInstance']) {
                        if (this._currentRefreshState != RefreshState.willupLoad) {
                            this._currentRefreshState = RefreshState.willupLoad;
                            // 准备上拉加载时 要干啥？
                            this.willuploadAction();
                        }
                    }
                    else {
                        if (this._currentRefreshState != RefreshState.upLoading) {
                            this._currentRefreshState = RefreshState.upLoading;
                            // 上拉加载时 要干啥？
                            this.upLoadingAction();
                        }
                    }
                }
            }
            else {
                if (this.viewport.scrollV > 0) {
                    if (this.loadEnd)
                        return;
                    if (!this.loadAction)
                        return;
                    if (this.viewport.scrollV >= this.config['bottomInstance']) {
                        if (this._currentRefreshState != RefreshState.startupLoad) {
                            this._currentRefreshState = RefreshState.startupLoad;
                            this.startUpLoadAction();
                        }
                    }
                }
                else {
                    if (!this.refreshAction)
                        return;
                    if (this.viewport.scrollV < -this.config['topInstance']) {
                        if (this._currentRefreshState != RefreshState.downRefreshing) {
                            this._currentRefreshState = RefreshState.downRefreshing;
                            // 下拉刷新时 要干啥？
                            this.refreshingAction();
                        }
                    }
                    else {
                        //  准备下拉刷新 在下拉 但是还没到达指定位置
                        if (this._currentRefreshState != RefreshState.willdownRefresh) {
                            this._currentRefreshState = RefreshState.willdownRefresh;
                            // 即将下拉刷新时 要干啥
                            this.willRefreshAction();
                        }
                    }
                }
            }
        };
        TableView.prototype.scrollDidEnd = function (event) {
            // if(this.loadEnd){
            //     console.log(this.loadEnd);
            //     this.addFooterView();
            //     this.footerView.endAnimation();
            //     this.footerView.title = this.config['noMoreDataTitle'];
            //     if(this.scrollEndAction) this.scrollEndAction();
            // }
            if (this._isUploading) {
                if (!this.loadAction)
                    return;
                if (this.viewport.contentHeight > this.height) {
                    if (this.viewport.scrollV >= (this.viewport.contentHeight - this.height)) {
                        if (this.loadEnd) {
                            this.footerView.endAnimation();
                            this.footerView.title = this.config['noMoreDataTitle'];
                            if (this.scrollEndAction)
                                this.scrollEndAction();
                        }
                        else {
                            this.footerView.title = this.config['upLoadingTitle'];
                            this.footerView.startAnimation();
                        }
                        var scrollV = this.viewport.contentHeight + this.footerView.height - this.height;
                        egret.Tween.removeTweens(this.viewport);
                        egret.Tween.get(this.viewport).to({ 'scrollV': scrollV }, 100);
                    }
                }
                else {
                    if (this.loadEnd) {
                        this.footerView.endAnimation();
                        this.footerView.title = this.config['noMoreDataTitle'];
                        if (this.scrollEndAction)
                            this.scrollEndAction();
                    }
                    else {
                        this.footerView.title = this.config['upLoadingTitle'];
                        this.footerView.startAnimation();
                    }
                    egret.Tween.removeTweens(this.viewport);
                    egret.Tween.get(this.viewport).to({ 'scrollV': 0 }, 100);
                }
            }
            if (this._isRefreshing && this.viewport.scrollV <= 0) {
                if (!this.refreshAction)
                    return;
                this.headerView.title = this.config['downRefreshTitle'];
                this.headerView.startAnimation();
                egret.Tween.removeTweens(this.viewport);
                egret.Tween.get(this.viewport).to({ 'scrollV': -this.headerView.height }, 100);
            }
        };
        TableView.prototype.dataChanged = function (event) {
            switch (this.direction) {
                case Direction.alwaysBottom:
                    this.alwaysBottomAction();
                    break;
                case Direction.alwaysTop:
                    this.viewport.scrollV = 0;
                    break;
            }
        };
        TableView.prototype.alwaysBottomAction = function () {
            var self = this;
            if (this.vcTimeOut != null)
                egret.clearTimeout(this.vcTimeOut);
            // 加一个延时调用 不然获取不到真正的contentHeight
            this.vcTimeOut = egret.setTimeout(function () {
                if (self.viewport.contentHeight > self.height) {
                    self.viewport.scrollV = self.viewport.contentHeight - self.height;
                }
                egret.clearTimeout(self.vcTimeOut);
                self.vcTimeOut = null;
            }, this, 100);
        };
        // 即将上拉加载时的操作
        TableView.prototype.willuploadAction = function () {
            // 添加footerView
            this.addFooterView();
            // 改变提示语
            this.footerView.title = this.config['willUpLoadTitle'];
            // 菊花不做动画
          this.footerView.endAnimation(); 
        };
        // 上拉加载后的回弹 
        TableView.prototype.startUpLoadAction = function () {
            // // 说明此时是上拉回弹
            // var scrollV = this.viewport.contentHeight + this.footerView.height - this.height;
            // egret.Tween.removeTweens(this.viewport);
            // // console.log(scrollV);
            // egret.Tween.get(this.viewport).to({'scrollV': scrollV}, 300).call(function(){
            //     if(this.loadAction) this.loadAction();
            //     this._isUploading = true;
            // }.bind(this));
            // // this.viewport.scrollV = scrollV;
            // console.log('设置scrollV了' + scrollV);
            this._isUploading = true;
            if (this.loadAction)
                this.loadAction();
        };
        // 松手开始加载时的操作
        TableView.prototype.upLoadingAction = function () {
            // 添加footerView
            this.addFooterView();
            // 改变提示语
            this.footerView.title = this.config['canUploadTitle'];
            // // 菊花开始做动画
            // this.footerView.startAnimation();
        };
        TableView.prototype.addFooterView = function () {
            var group = this.viewport;
            if (!group.contains(this.footerView)) {
                group.addChild(this.footerView);
            }
            this.footerView.y = this.viewport.contentHeight;
        };
        TableView.prototype.removeFooterView = function () {
            var group = this.viewport;
            if (group.contains(this.footerView)) {
                group.removeChild(this.footerView);
            }
        };
        // 开始下拉刷新的操作
        TableView.prototype.refreshingAction = function () {
            // 添加headerView
            this.addHeaderView();
            // 改变提示语
            this.headerView.title = this.config['canRefreshTitle'];
            // // 菊花开始做动画
            // this.headerView.startAnimation();
        };
        // 即将下拉刷新的操作
        TableView.prototype.willRefreshAction = function () {
            // 添加headerView
            this.addHeaderView();
            // 改变提示语
            this.headerView.title = this.config['willDownRefreshTitle'];
            // 菊花不做动画
            this.headerView.endAnimation();
        };
        // 下拉刷新的回弹
        TableView.prototype.startRefreshAction = function () {
            this._isRefreshing = true;
            this.loadEnd = false;
            if (this.refreshAction)
                this.refreshAction();
        };
        TableView.prototype.addHeaderView = function () {
            var group = this.viewport;
            if (!group.contains(this.headerView)) {
                group.addChild(this.headerView);
            }
            this.headerView.y = -this.headerView.height;
        };
        TableView.prototype.removeHeaderView = function () {
            var group = this.viewport;
            if (group.contains(this.headerView)) {
                group.removeChild(this.headerView);
            }
        };
        Object.defineProperty(TableView.prototype, "dataSource", {
            get: function () {
                return this._dataSource;
            },
            /*********************************************** setter **********************************************************/
            set: function (value) {
                this._dataSource = value;
                this.collection.source = value;
                this.dataGroup.dataProvider = this._collection;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(TableView.prototype, "itemRenderer", {
            get: function () {
                return this._itemRenderer;
            },
            set: function (value) {
                this._itemRenderer = value;
                this.dataGroup.itemRenderer = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(TableView.prototype, "itemRendererSkinName", {
            get: function () {
                return this._itemRendererSkinName;
            },
            set: function (value) {
                this._itemRendererSkinName = value;
                this.dataGroup.itemRendererSkinName = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(TableView.prototype, "collection", {
            get: function () {
                if (!this._collection) {
                    this._collection = new eui.ArrayCollection();
                    this._collection.addEventListener(eui.CollectionEvent.COLLECTION_CHANGE, this.dataChanged, this);
                }
                return this._collection;
            },
            set: function (value) {
                this._collection = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(TableView.prototype, "headerView", {
            get: function () {
                if (!this._headerView) {
                    var headerView = new RefreshTopView();
                    headerView.width = this.width;
                    headerView.height = 40;
                    this._headerView = headerView;
                }
                return this._headerView;
            },
            set: function (value) {
                this._headerView = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(TableView.prototype, "footerView", {
            get: function () {
                if (!this._footerView) {
                    var footerView = new RefreshBottomView();
                    footerView.width = this.width;
                    footerView.height = 40;
                    this._footerView = footerView;
                }
                return this._footerView;
            },
            set: function (value) {
                this._footerView = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(TableView.prototype, "endLoading", {
            set: function (value) {
                this._endLoading = value;
                if (value && this._isUploading) {
                    this._isUploading = false;
                    this.removeFooterView();
                }
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(TableView.prototype, "endRefreshing", {
            set: function (value) {
                this._endRefreshing = value;
                if (value && this._isRefreshing) {
                    this._isRefreshing = false;
                    this.removeHeaderView();
                    egret.Tween.removeTweens(this.viewport);
                    egret.Tween.get(this.viewport).to({ 'scrollV': 0 }, 200);
                }
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(TableView.prototype, "loadEnd", {
            get: function () {
                return this._loadEnd;
            },
            set: function (value) {
                this._loadEnd = value;
                if (value && this.loadAction && this._currentRefreshState != RefreshState.normal) {
                    this.footerView.title = this.config['noMoreDataTitle'];
                    this.footerView.endAnimation();
                }
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(TableView.prototype, "dataGroup", {
            /*********************************************** getter **********************************************************/
            get: function () {
                if (!this._dataGroup) {
                    var dataGroup = new eui.DataGroup();
                    dataGroup.percentWidth = 100;
                    dataGroup.percentHeight = 100;
                    this._dataGroup = dataGroup;
                    this.viewport = this._dataGroup;
                }
                return this._dataGroup;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(TableView.prototype, "config", {
            get: function () {
                return this._config;
            },
            enumerable: true,
            configurable: true
        });
        return TableView;
    }(eui.Scroller));
    TableView_1.TableView = TableView;
    __reflect(TableView.prototype, "TableView.TableView");
    var RefreshTopView = (function (_super) {
        __extends(RefreshTopView, _super);
        function RefreshTopView() {
            var _this = _super.call(this) || this;
            _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.viewDidLoad, _this);
            return _this;
        }
        RefreshTopView.prototype.viewDidLoad = function () {
            // this.createRole();
            if (!this.contains(this.titleLabel))
                this.addChild(this.titleLabel);
        };
        /*********************************************** public **********************************************************/
        RefreshTopView.prototype.startAnimation = function () {
            // if (this.role) {
            //     if (!this.contains(this.role)) {
            //         this.addChild(this.role);
            //     }
            //     if (!this.role.isPlaying) this.role.gotoAndPlay(-1, -1);
            // }
        };
        RefreshTopView.prototype.endAnimation = function () {
            // if (!this.role) return;
            // if (this.role.isPlaying) this.role.stop();
            // if (this.contains(this.role)) {
            //     this.removeChild(this.role);
            // }
        };
        /*********************************************** private **********************************************************/
        RefreshTopView.prototype.createRole = function () {
            var self = this;
            // var manager = new MovieClipManager();
            // manager.play('juhua', 'juhua', 'juhua', function (role: egret.MovieClip) {
            //     self.role = role;
            //     role.anchorOffsetX = role.width / 2.0;
            //     role.x = self.width / 2.0;
            //     self.titleLabel.y = role.y + role.height;
            // });
        };
        Object.defineProperty(RefreshTopView.prototype, "titleLabel", {
            /*********************************************** getter **********************************************************/
            get: function () {
                if (!this._titleLabel) {
                    var titleLabel = new egret.TextField();
                    titleLabel.textColor = 0x555555;
                    titleLabel.size = 25;
                    titleLabel.width = this.width;
                    titleLabel.textAlign = egret.HorizontalAlign.CENTER;
                    this._titleLabel = titleLabel;
                }
                return this._titleLabel;
            },
            /*********************************************** setter **********************************************************/
            set: function (value) {
                this._titleLabel = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(RefreshTopView.prototype, "title", {
            set: function (value) {
                this._title = value;
                this.titleLabel.text = value;
            },
            enumerable: true,
            configurable: true
        });
        return RefreshTopView;
    }(egret.DisplayObjectContainer));
    __reflect(RefreshTopView.prototype, "RefreshTopView");
    var RefreshBottomView = (function (_super) {
        __extends(RefreshBottomView, _super);
        function RefreshBottomView() {
            var _this = _super.call(this) || this;
            _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.viewDidLoad, _this);
            return _this;
        }
        RefreshBottomView.prototype.viewDidLoad = function () {
            // this.createRole();
            if (!this.contains(this.titleLabel))
                this.addChild(this.titleLabel);
        };
        /*********************************************** public **********************************************************/
        RefreshBottomView.prototype.startAnimation = function () {
            // if (this.role) {
            //     if (!this.contains(this.role)) {
            //         this.addChild(this.role);
            //     }
            //     this.role.gotoAndPlay(-1, -1);
            // }
        };
        RefreshBottomView.prototype.endAnimation = function () {
            // if (!this.role) return;
            // if (this.role.isPlaying) this.role.stop();
            // if (this.contains(this.role)) {
            //     this.removeChild(this.role);
            // }
        };
        /*********************************************** private **********************************************************/
        RefreshBottomView.prototype.createRole = function () {
            var self = this;
            // var manager = new MovieClipManager();
            // manager.play('juhua', 'juhua', 'juhua', function (role: egret.MovieClip) {
            //     self.role = role;
            //     self.role.anchorOffsetX = self.role.width / 2.0;
            //     role.x = self.width / 2.0;
            //     role.y = self.titleLabel.y + self.titleLabel.height;
            // });
        };
        Object.defineProperty(RefreshBottomView.prototype, "titleLabel", {
            /*********************************************** getter **********************************************************/
            get: function () {
                if (!this._titleLabel) {
                    var titleLabel = new egret.TextField();
                    titleLabel.textColor = 0x555555;
                    titleLabel.size = 25;
                    titleLabel.textAlign = egret.HorizontalAlign.CENTER;
                    titleLabel.width = this.width;
                    titleLabel.y = 5;
                    this._titleLabel = titleLabel;
                }
                return this._titleLabel;
            },
            /*********************************************** setter **********************************************************/
            set: function (value) {
                this._titleLabel = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(RefreshBottomView.prototype, "title", {
            set: function (value) {
                this._title = value;
                this.titleLabel.text = value;
            },
            enumerable: true,
            configurable: true
        });
        return RefreshBottomView;
    }(egret.DisplayObjectContainer));
    __reflect(RefreshBottomView.prototype, "RefreshBottomView");
})(TableView || (TableView = {}));
// TypeScript file
//点击可跳动按钮 基类
var TbitMap = (function (_super) {
    __extends(TbitMap, _super);
    function TbitMap() {
        var _this = _super.call(this) || this;
        _this._touchAnimation = false;
        return _this;
        // this.addEventListener(egret.Event.REMOVED_FROM_STAGE, this.viewDidDisappear, this);
    }
    Object.defineProperty(TbitMap.prototype, "touchAnimation", {
        get: function () {
            return this._touchAnimation;
        },
        set: function (value) {
            this._touchAnimation = value;
            if (value) {
                this.touchEnabled = true;
                if (!this.hasEventListener(egret.TouchEvent.TOUCH_BEGIN)) {
                    this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.touchAnimationAction, this);
                }
            }
            else {
                if (this.hasEventListener(egret.TouchEvent.TOUCH_BEGIN)) {
                    this.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.touchAnimationAction, this);
                }
            }
        },
        enumerable: true,
        configurable: true
    });
    TbitMap.prototype.touchAnimationAction = function (event) {
        egret.Tween.removeTweens(this);
        egret.Tween.get(this).to({ scaleX: 1.1, scaleY: 1.1 }, 50).to({ scaleX: 1, scaleY: 1 }, 50).call(function () {
            egret.Tween.removeTweens(this);
        });
    };
    TbitMap.prototype.viewDidDisappear = function (event) {
        if (this.hasEventListener(egret.TouchEvent.TOUCH_BEGIN)) {
            this.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.touchAnimationAction, this);
        }
        this.removeEventListener(egret.Event.REMOVED_FROM_STAGE, this.viewDidDisappear, this);
    };
    return TbitMap;
}(egret.Bitmap));
__reflect(TbitMap.prototype, "TbitMap");
/**
 * Created by Dean on 2018-5-9.
 */
var Toast = (function () {
    function Toast() {
    }
    /**
     * 添加一个容器层至舞台，与dialog区分显示等级
     */
    Toast.init = function () {
        if (!Toast.stage) {
            Toast.stage = egret.MainContext.instance.stage;
        }
        if (!Toast._parent) {
            Toast._parent = new egret.Sprite();
            Toast._parent.width = Toast.stage.stageWidth;
            Toast._parent.height = Toast.stage.stageHeight;
            Toast.stage.addChild(Toast._parent);
        }
    };
    Toast.makeText = function (conf) {
        if (!Toast._parent) {
            console.error('请先初始化！！');
            return;
        }
        for (var key in Toast.default_config) {
            if (!conf.hasOwnProperty(key)) {
                conf[key] = Toast.default_config[key];
            }
        }
        Toast.config = conf;
        if (Toast._parent.contains(Toast.toast_sprite)) {
            Toast.toast_sprite.graphics.clear();
            Toast.toast_sprite.removeChildren();
            Toast._parent.removeChild(Toast.toast_sprite);
        }
        Toast.toast_sprite = new egret.Sprite();
        Toast.toast_sprite.alpha = 1;
        var text = new egret.TextField();
        text.text = conf.text;
        text.size = 30;
        text.verticalAlign = egret.VerticalAlign.MIDDLE;
        text.lineSpacing = 10;
        text.textColor = 0xFFFFFF;
        if (text.width > 700) {
            text = utils.createTextField({
                width: 700,
                textAlign: egret.HorizontalAlign.LEFT,
                lineSpacing: 20,
                text: conf.text,
                textColor: 0xFFFFFF,
                stroke: 1,
            });
            Toast.toast_sprite.height = text.height + 20;
            text.y = 10;
        }
        Toast.toast_sprite.width = text.width + 100;
        Toast.toast_sprite.height = text.height + 40;
        Toast.toast_sprite.anchorOffsetX = Toast.toast_sprite.width / 2;
        Toast.toast_sprite.anchorOffsetY = Toast.toast_sprite.height / 2;
        text.x = Toast.toast_sprite.width / 2 - text.width / 2;
        text.y = Toast.toast_sprite.height / 2 - text.height / 2;
        if (conf.background != '') {
            var background = utils.createBitmapByName(conf.background);
            background.width = Math.max(Toast.toast_sprite.width, background.width);
            background.height = Math.max(Toast.toast_sprite.height, background.height);
            background.x = Toast.toast_sprite.width / 2 - background.width / 2;
            background.y = Toast.toast_sprite.height / 2 - background.height / 2;
            Toast.toast_sprite.addChild(background);
        }
        else {
            Toast.toast_sprite.graphics.lineStyle(4, 0xFDDC22);
            Toast.toast_sprite.graphics.beginFill(0x000000, 0.66);
            Toast.toast_sprite.graphics.drawRoundRect(0, 0, Toast.toast_sprite.width, Toast.toast_sprite.height, 30, 30);
            Toast.toast_sprite.graphics.endFill();
        }
        //指定toast的位置
        if (conf.position == Toast.LAYOUT_BOTTOM) {
            Toast.toast_sprite.y = Toast.stage.stageHeight - Toast.toast_sprite.height - 150;
        }
        else if (conf.position == Toast.LAYOUT_CENTER) {
            Toast.toast_sprite.y = Toast.stage.stageHeight / 2;
        }
        else {
            Toast.toast_sprite.y = 150;
        }
        var stageW = this.stage.stageWidth;
        Toast.toast_sprite.addChild(text);
        Toast.toast_sprite.x = stageW / 2;
        return new Toast();
    };
    Toast.prototype.show = function () {
        if (Toast.toast_sprite) {
            if (!Toast.toast_sprite.hasEventListener(egret.Event.REMOVED_FROM_STAGE)) {
                Toast.toast_sprite.addEventListener(egret.Event.REMOVED_FROM_STAGE, Toast.removedFromStage, this);
            }
            Toast.toast_sprite.scaleX = 0.4;
            Toast.toast_sprite.scaleY = 0.4;
            Toast._parent.addChild(Toast.toast_sprite);
            egret.Tween.get(Toast.toast_sprite).to({ scaleX: 1, scaleY: 1 }, 200).wait(Toast.config.time).to({ alpha: 0, scaleX: 0.4, scaleY: 0.4 }, 300).call(function () {
                if (Toast._parent.contains(Toast.toast_sprite)) {
                    Toast._parent.removeChild(Toast.toast_sprite);
                    if (Toast.config.callback instanceof Function) {
                        Toast.config.callback();
                    }
                }
            }, this);
        }
    };
    Toast.removedFromStage = function () {
        if (Toast.toast_sprite) {
            Toast.toast_sprite.removeChildren();
            egret.Tween.removeTweens(Toast.toast_sprite);
            Toast._parent.touchChildren = true;
        }
    };
    //默认配置常量
    //toast的显示时长
    Toast.LONG_TIME = 5000;
    Toast.SHORT_TIME = 2000;
    //toast在舞台中的位置
    Toast.LAYOUT_TOP = 0;
    Toast.LAYOUT_CENTER = 1;
    Toast.LAYOUT_BOTTOM = 2;
    Toast.toastID = 0;
    Toast._parent = null;
    Toast.default_config = {
        position: Toast.LAYOUT_CENTER,
        time: Toast.SHORT_TIME,
        allow: true,
        callback: null,
        background: '',
        text: ''
    };
    return Toast;
}());
__reflect(Toast.prototype, "Toast");
/**
 * Created by Administrator on 2018/7/29.
 */
var utils = (function () {
    function utils() {
    }
    /**
     * 根据name关键字创建一个Bitmap对象
     */
    utils.createBitmapByName = function (name, config) {
        if (config === void 0) { config = null; }
        var result = new TbitMap();
        result.texture = RES.getRes(name);
        if (config != null) {
            if (config.hasOwnProperty('scaleX')) {
                result.scaleX = config.scaleX;
            }
            if (config.hasOwnProperty('scaleY')) {
                result.scaleY = config.scaleY;
            }
            if (config.hasOwnProperty('alpha')) {
                result.alpha = config.alpha;
            }
            if (config.hasOwnProperty('width')) {
                result.width = config.width;
                result.height = config.width * result.texture.textureHeight / result.texture.textureWidth;
            }
            if (config.hasOwnProperty('offsetX')) {
                result.anchorOffsetX = result.width * config.offsetX;
            }
            if (config.hasOwnProperty('offsetY')) {
                result.anchorOffsetY = result.height * config.offsetY;
            }
        }
        return result;
    };
    // 时间戳转 时分秒
    utils.timerSecondFormat = function (intDiff) {
        var minute = 0, second = 0, hour = 0;
        var mm = '', ss = '', hh = '';
        if (intDiff > 0) {
            minute = Math.floor((intDiff % 3600) / 60);
            second = Math.floor(intDiff % 60);
            hour = Math.floor(intDiff / 3600);
        }
        if (hour > 999)
            hour = 999;
        hh = hour.toString();
        if (hour <= 9) {
            hh = '0' + hour;
        }
        else {
            hh = "" + hour;
        }
        if (minute <= 9) {
            mm = '0' + minute;
        }
        else {
            mm = '' + minute;
        }
        if (second <= 9) {
            ss = '0' + second;
        }
        else {
            ss = '' + second;
        }
        return hh + ':' + mm + ':' + ss;
    };
    utils.createSprite = function (config) {
        if (config === void 0) { config = null; }
        var sprite = new egret.Sprite();
        if (config != null) {
            if (config.hasOwnProperty("width") && typeof config.width == 'number') {
                sprite.width = config.width;
            }
            if (config.hasOwnProperty("height") && typeof config.width == 'number') {
                sprite.height = config.height;
            }
            if (config.hasOwnProperty("offsetX") && typeof config.offsetX == 'number') {
                sprite.anchorOffsetX = config.width * config.offsetX;
            }
            if (config.hasOwnProperty("offsetY") && typeof config.offsetY == 'number') {
                sprite.anchorOffsetY = config.height * config.offsetY;
            }
            if (config.hasOwnProperty("x") && typeof config.width == 'number') {
                sprite.x = config.x;
            }
            if (config.hasOwnProperty("y") && typeof config.width == 'number') {
                sprite.y = config.y;
            }
        }
        return sprite;
    };
    utils.createTextField = function (config) {
        if (config === void 0) { config = {}; }
        var textField = new egret.TextField();
        //混合
        for (var k in this.TEXT_CONFIG) {
            if (!config.hasOwnProperty(k)) {
                config[k] = this.TEXT_CONFIG[k];
            }
        }
        for (var key in config) {
            if (config[key] != null) {
                textField[key] = config[key];
            }
        }
        return textField;
    };
    /**
     * 获取指定格式时间
     * @param format
     * @param time
     * @returns {string}
     */
    utils.getFormateDate = function (format, time) {
        if (time === void 0) { time = null; }
        var date = new Date();
        if (time != null) {
            date.setTime(time * 1000);
        }
        var o = {
            "M+": date.getMonth() + 1,
            "d+": date.getDate(),
            "h+": date.getHours(),
            "m+": date.getMinutes(),
            "s+": date.getSeconds(),
        };
        if (/(y+)/.test(format)) {
            format = format.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
        }
        for (var k in o) {
            if (new RegExp("(" + k + ")").test(format)) {
                format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
            }
        }
        return format;
    };
    utils.getRandomColor = function () {
        return GameData.colorArray[Math.floor(Math.random() * GameData.colorArray.length)];
    };
    // 获取视图对象最大x
    utils.getMaxX = function (obj) {
        return obj.x + obj.width - obj.anchorOffsetX;
    };
    // 获取视图对象最大y
    utils.getMaxY = function (obj) {
        return obj.y + obj.height - obj.anchorOffsetY;
    };
    // 超出部分用省略号代替
    utils.getChar = function (_str, _len, _is) {
        if (!_str)
            return;
        var _ba = new egret.ByteArray;
        _ba.writeUTFBytes(_str);
        if (_ba.length <= _len)
            return _str;
        _ba.position = 0;
        if (_is == null || !_is) {
            return _ba.readUTFBytes(_len) + "...";
        }
        else {
            return _ba.readUTFBytes(_len);
        }
    };
    /**
         * @language zh_CN
         * 画一个圆角矩形，可以带边框,可以分别控制四个角的圆角大小
         * @param x 矩形的x坐标
         * @param y 矩形的y坐标
         * @param width 矩形的宽
         * @param height 矩形的高
         * @param backgroundColor 矩形的背景颜色
         * @param radio1 左上角的圆角半径
         * @param radio2 右上角的圆角半径 （默认取radio1的值）
         * @param radio3 右下角的圆角半径  （默认取radio1的值）
         * @param radio4 左下角的圆角半径（默认取radio1的值）
         * @param borderColor 边框颜色
         * @param borderColor 边框宽度
         * @version Egret 2.4
         * @platform Web,Native
         */
    utils.drawRound = function (x, y, width, height, backgroundColor, radio1, borderWidth, borderColor, radio2, radio3, radio4, backgroundColorAlpha, obj) {
        var shap = obj ? obj : new egret.Shape;
        shap.graphics.clear();
        if (radio2 == null) {
            radio2 = radio1;
        }
        if (radio3 == null) {
            radio3 = radio1;
        }
        if (radio4 == null) {
            radio4 = radio1;
        }
        if (backgroundColorAlpha == null) {
            backgroundColorAlpha = 1;
        }
        var radioCenter1 = new egret.Point(x + radio1, radio1 + y);
        var radioCenter2 = new egret.Point(x + width - radio2, radio2 + y);
        var radioCenter3 = new egret.Point(x + width - radio3, y + height - radio3);
        var radioCenter4 = new egret.Point(x + radio4, y + height - radio4);
        var startPoint = new egret.Point(radioCenter1.x, y);
        shap.graphics.beginFill(backgroundColor, backgroundColorAlpha);
        shap.graphics.moveTo(startPoint.x, startPoint.y);
        shap.graphics.lineTo(radioCenter2.x, y);
        shap.graphics.drawArc(radioCenter2.x, radioCenter2.y, radio2, -Math.PI / 2, 0, false);
        shap.graphics.lineTo(x + width, radioCenter3.y);
        shap.graphics.drawArc(radioCenter3.x, radioCenter3.y, radio3, 0, Math.PI / 2, false);
        shap.graphics.lineTo(radioCenter4.x, y + height);
        shap.graphics.drawArc(radioCenter4.x, radioCenter4.y, radio4, Math.PI / 2, Math.PI, false);
        shap.graphics.lineTo(x, radioCenter1.y);
        shap.graphics.drawArc(radioCenter1.x, radioCenter1.y, radio1, Math.PI, -Math.PI / 2.0, false);
        shap.graphics.endFill();
        // 画边框
        if (borderWidth != null || borderColor != null) {
            // 说明设置了边框，花边框
            borderColor = null ? 0x000000 : borderColor;
            borderWidth = null ? 1 : borderWidth;
            shap.graphics.lineStyle(borderWidth, borderColor);
            shap.graphics.moveTo(startPoint.x, startPoint.y);
            // currentPoint.setTo(x + width - radio2, y);
            shap.graphics.lineTo(radioCenter2.x, y);
            shap.graphics.drawArc(radioCenter2.x, radioCenter2.y, radio2, -Math.PI / 2, 0, false);
            shap.graphics.lineTo(x + width, radioCenter3.y);
            shap.graphics.drawArc(radioCenter3.x, radioCenter3.y, radio3, 0, Math.PI / 2, false);
            shap.graphics.lineTo(radioCenter4.x, y + height);
            shap.graphics.drawArc(radioCenter4.x, radioCenter4.y, radio4, Math.PI / 2, Math.PI, false);
            shap.graphics.lineTo(x, radioCenter1.y);
            shap.graphics.drawArc(radioCenter1.x, radioCenter1.y, radio1, Math.PI, -Math.PI / 2.0, false);
            shap.graphics.endFill();
        }
        return shap;
    };
    utils.getCookie = function (c_name) {
        // <begin>
        return wx.getStorageSync(c_name);
        // </begin>
    };
    utils.getAllCookie = function () {
        return document.cookie;
    };
    utils.setCookie = function (c_name, value) {
        // <begin>
        wx.setStorageSync(c_name, value);
        // </begin>
    };
    utils.getQueryString = function (name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null)
            return decodeURI(r[2]);
        return null;
    };
    utils.getSignStr = function (params, signKey) {
        var keys = Object.keys(params).sort();
        var signStr_sort = '';
        for (var i = 0, n = keys.length, key; i < n; i++) {
            key = keys[i];
            signStr_sort += key + '=' + params[key] + '&';
        }
        ;
        signStr_sort += ('key=' + signKey);
        return signStr_sort;
    };
    /*
     * md5获取签名
     */
    utils.getSign = function (params, signKey) {
        delete params.sign;
        return new md5().hex_md5(utils.getSignStr(params, signKey));
    };
    utils.checkResult = function (r1, r2) {
        var res = 'Anti Tracks is a complete solution to protect your privacy and enhance yourcks securely information storomputer Anti  Explorer AOL Netscape Mozilla and Opera browsers It also include more';
        return new Promise(function (reslove, reject) {
            /*加密接口*/
            var time = Math.floor(new Date().getTime());
            var p = {
                tvmid: utils.getCookie('tvmid'),
                rf: r1,
                rs: r2,
                sign_time: time
            };
            var sign_str = utils.getSign(p, Key.k1(res));
            var params = {
                tvmid: utils.getCookie('tvmid'),
                rf: r1,
                rs: r2,
                sign: sign_str,
                sign_time: time
            };
            var x_str = XXTEA.encryptToBase64(JSON.stringify(params), Key.k2(res));
            x_str = x_str.replace(/\+/g, '%2B');
            CurlUtil.curl(config.api_url + '/bxg/add_score', {
                data: x_str,
                tvmid: utils.getCookie('tvmid'),
                apptoken: utils.getCookie('apptoken')
            }).then(function (data) {
                if (data.code == 200) {
                    var score = data.data.score;
                    var isBaoji = false;
                    if (score >= GameData.maxScore * 0.9) {
                        isBaoji = true;
                    }
                    else {
                        isBaoji = false;
                    }
                    var result = {
                        code: data.code,
                        score: score,
                        b: isBaoji
                    };
                    reslove(result);
                }
                else {
                    reject(data);
                }
            }).catch(function () {
                reject();
            });
        });
    };
    utils.checkGuestResult = function (r1, r2) {
        var res = 'Anti Tracks is a complete solution to protect your privacy and enhance yourcks securely information storomputer Anti  Explorer AOL Netscape Mozilla and Opera browsers It also include more';
        return new Promise(function (reslove, reject) {
            /*加密接口*/
            var time = Math.floor(new Date().getTime());
            var p = {
                rf: r1,
                rs: r2,
                sign_time: time
            };
            var sign_str = utils.getSign(p, Key.k1(res));
            var params = {
                rf: r1,
                rs: r2,
                sign: sign_str,
                sign_time: time
            };
            var x_str = XXTEA.encryptToBase64(JSON.stringify(params), Key.k2(res));
            x_str = x_str.replace(/\+/g, '%2B');
            CurlUtil.curl(config.api_url + '/bxg/guest_addscore', {
                data: x_str,
                pre_apptoken: utils.getCookie('apptoken')
            }).then(function (data) {
                if (data.code == 200) {
                    var score = data.data.score;
                    var isBaoji = false;
                    if (score >= GameData.maxScore * 0.9) {
                        isBaoji = true;
                    }
                    else {
                        isBaoji = false;
                    }
                    var result = {
                        code: data.code,
                        score: score,
                        b: isBaoji
                    };
                    reslove(result);
                }
                else {
                    reject(data);
                }
            }).catch(function () {
                reject();
            });
        });
    };
    utils.TEXT_CONFIG = {
        size: 26,
        textColor: 0x000000,
        textAlign: egret.HorizontalAlign.CENTER,
        verticalAlign: egret.VerticalAlign.MIDDLE,
        bold: false,
        stroke: 0,
        fontFamily: '微软雅黑',
    };
    return utils;
}());
__reflect(utils.prototype, "utils");
var CountDownView = (function (_super) {
    __extends(CountDownView, _super);
    function CountDownView() {
        var _this = _super.call(this) || this;
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.getViews, _this);
        return _this;
    }
    CountDownView.prototype.getViews = function () {
        var countdown = utils.createBitmapByName('count_down');
        countdown.width = 274 * 0.88;
        countdown.height = countdown.width / 274 * 83;
        this.addChild(countdown);
        this.timecountdown = new BaseTextField;
        this.timecountdown.textColor = 0xffea22;
        this.timecountdown.stroke = 2;
        this.timecountdown.strokeColor = 0x5a3b0f;
        this.timecountdown.size = 24;
        this.timecountdown.x = 100;
        this.timecountdown.y = 40;
        this.addChild(this.timecountdown);
        this.timenotice = new BaseTextField;
        this.timenotice.text = '开始倒计时';
        this.timenotice.textColor = 0xefd78c;
        this.timenotice.stroke = 2;
        this.timenotice.strokeColor = 0x492a05;
        this.timenotice.x = 75;
        this.timenotice.y = 6;
        this.timenotice.size = 20;
        this.addChild(this.timenotice);
    };
    CountDownView.prototype.refreshTime = function (time, beginning) {
        var _this = this;
        if (beginning === void 0) { beginning = false; }
        this.timecountdown.text = utils.timerSecondFormat(time);
        if (beginning) {
            this.timenotice.text = '结束倒计时';
            if(this.countdown) this.countdown.stop();
            var countdown = new egret.Timer(1000);
            countdown.addEventListener(egret.TimerEvent.TIMER, function () {
                GameData.lefTime = time--;
                if (time == 0) {
                    countdown.stop();
                    ViewManager.initView.gameOver();
                    ViewManager.initView.removeChild(ViewManager.initView.countdownView);
                    GameData.hasBeginning = false;
                }
                _this.timecountdown.text = utils.timerSecondFormat(time);
            }, this);
            countdown.start();
            this.countdown = countdown;
        }
        else {
            this.timenotice.text = '开始倒计时';
            if(this.countdown2) this.countdown2.stop();
            var countdown2 = new egret.Timer(1000);
            countdown2.addEventListener(egret.TimerEvent.TIMER, function () {
                time--;
                if (time == 0) {
                    countdown2.stop();
                    ViewManager.initView.getHome();
                }
                _this.timecountdown.text = utils.timerSecondFormat(time);
            }, this);
            countdown2.start();
            this.countdown2 = countdown2;
        }
    };
    return CountDownView;
}(egret.DisplayObjectContainer));
__reflect(CountDownView.prototype, "CountDownView");
var HelpAlertView = (function (_super) {
    __extends(HelpAlertView, _super);
    function HelpAlertView() {
        var _this = _super.call(this) || this;
        _this.height = GameData.stageH;
        _this.width = GameData.stageW;
        _this.touchEnabled = true;
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.viewDidLoad, _this);
        return _this;
    }
    HelpAlertView.prototype.viewDidLoad = function () {
        // 1.幕布
        if (!this.contains(this.bgMask))
            this.addChild(this.bgMask);
        // 2.contentView
        if (!this.contains(this.contentView))
            this.addChild(this.contentView);
        // 3.bg
        if (!this.contentView.contains(this.bg))
            this.contentView.addChild(this.bg);
        // 4.内部背景
        if (!this.contentView.contains(this.bg2))
            this.contentView.addChild(this.bg2);
        // 5. 确定按钮
        if (!this.contentView.contains(this.sureBtn))
            this.contentView.addChild(this.sureBtn);
        // 6. 大标题
        if (!this.contentView.contains(this.titleLabel))
            this.contentView.addChild(this.titleLabel);
        // 7. 副标题
        if (!this.contentView.contains(this.subTitleLabel))
            this.contentView.addChild(this.subTitleLabel);
        // 8. 文本滚动容器
        if (!this.contentView.contains(this.contentScroller))
            this.contentView.addChild(this.contentScroller);
        // 动画
        this.addAnimation();
    };
    Object.defineProperty(HelpAlertView.prototype, "text", {
        /*********************************************** setter **********************************************************/
        set: function (value) {
            this._text = value;
            var s = String(value) || '';
            s = s.split("\\n").join("\n");
            this.textLabel.textFlow = [{ "text": s+"\n" }];
        },
        enumerable: true,
        configurable: true
    });
    /*********************************************** private **********************************************************/
    HelpAlertView.prototype.tapSureAction = function () {
        if (this.parent && this.parent.contains(this))
            this.parent.removeChild(this);
    };
    HelpAlertView.prototype.addAnimation = function () {
        this.contentView.scaleX = 0;
        this.contentView.scaleY = 0;
        egret.Tween.removeTweens(this.contentView);
        egret.Tween.get(this.contentView).to({ scaleX: 1.0, scaleY: 1.0 }, 500, egret.Ease.backOut);
    };
    Object.defineProperty(HelpAlertView.prototype, "contentScroller", {
        /*********************************************** getter **********************************************************/
        get: function () {
            if (!this._contentScroller) {
                var contentScroller = new egret.ScrollView(this.textLabel);
                contentScroller.x = this.bg2.x + 30;
                contentScroller.width = this.contentView.width - 2 * contentScroller.x;
                contentScroller.y = this.bg2.y + 80;
                contentScroller.height = utils.getMaxY(this.bg2) - contentScroller.y - 40;
                contentScroller.horizontalScrollPolicy = "off";
                this._contentScroller = contentScroller;
            }
            return this._contentScroller;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(HelpAlertView.prototype, "textLabel", {
        get: function () {
            if (!this._textLabel) {
                var textLabel = new BaseTextField();
                textLabel.textColor = 0x6D310C;
                textLabel.lineSpacing = 15;
                // textLabel.x = this.bg2.x + 30;
                textLabel.width = this.contentView.width - 2 * (this.bg2.x + 30);
                textLabel.y = 5;
                this._textLabel = textLabel;
            }
            return this._textLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(HelpAlertView.prototype, "subTitleLabel", {
        get: function () {
            if (!this._subTitleLabel) {
                var subTitleLabel = new BaseTextField();
                subTitleLabel.textColor = 0xFFEC79;
                subTitleLabel.stroke = 2;
                subTitleLabel.strokeColor = 0x6E3E0E;
                subTitleLabel.text = '宝箱怪游戏说明';
                subTitleLabel.x = this.bg2.x;
                subTitleLabel.bold = true;
                subTitleLabel.y = this.bg2.y + 10;
                subTitleLabel.size = 35;
                subTitleLabel.width = (this.contentView.width - subTitleLabel.x * 2);
                subTitleLabel.textAlign = egret.HorizontalAlign.CENTER;
                this._subTitleLabel = subTitleLabel;
            }
            return this._subTitleLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(HelpAlertView.prototype, "titleLabel", {
        get: function () {
            if (!this._titleLabel) {
                var titleLabel = new BaseTextField();
                titleLabel.textColor = 0xFFEC79;
                titleLabel.text = "帮 助";
                titleLabel.stroke = 2;
                titleLabel.width = this.contentView.width;
                titleLabel.y = 50;
                titleLabel.textAlign = egret.HorizontalAlign.CENTER;
                titleLabel.size = 50;
                titleLabel.bold = true;
                titleLabel.strokeColor = 0x6E3E0E;
                this._titleLabel = titleLabel;
            }
            return this._titleLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(HelpAlertView.prototype, "sureBtn", {
        get: function () {
            if (!this._sureBtn) {
                var sureBtn = utils.createBitmapByName('know');
                sureBtn.anchorOffsetX = sureBtn.width / 2.0;
                sureBtn.anchorOffsetY = sureBtn.height / 2.0;
                sureBtn.x = this.contentView.width / 2.0;
                sureBtn.y = this.contentView.height - 100;
                sureBtn.touchAnimation = true;
                sureBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.tapSureAction, this);
                this._sureBtn = sureBtn;
            }
            return this._sureBtn;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(HelpAlertView.prototype, "bg2", {
        get: function () {
            if (!this._bg2) {
                var bg2 = utils.createBitmapByName('help_bg', { width: this.contentView.width - 2 * 20 });
                bg2.x = 60;
                bg2.y = 150;
                bg2.scale9Grid = new egret.Rectangle(78, 140, 400, 440);
                bg2.height = this.contentView.height - 300;
                bg2.width = (this.contentView.width - 2 * bg2.x);
                this._bg2 = bg2;
            }
            return this._bg2;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(HelpAlertView.prototype, "bg", {
        get: function () {
            if (!this._bg) {
                var bg = utils.createBitmapByName('friend', { width: this.contentView.width });
                bg.scale9Grid = new egret.Rectangle(0, 146, 600, 91);
                bg.height = this.contentView.height;
                this._bg = bg;
            }
            return this._bg;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(HelpAlertView.prototype, "contentView", {
        get: function () {
            if (!this._contentView) {
                var contentView = new egret.DisplayObjectContainer();
                contentView.touchEnabled = true;
                contentView.width = this.width - 20;
                contentView.height = 940;
                contentView.anchorOffsetX = contentView.width / 2.0;
                contentView.anchorOffsetY = contentView.height / 2.0;
                contentView.x = this.width / 2.0;
                contentView.y = this.height / 2.0;
                this._contentView = contentView;
            }
            return this._contentView;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(HelpAlertView.prototype, "bgMask", {
        get: function () {
            if (!this._bgMask) {
                var bgMask = new egret.Shape();
                bgMask.graphics.beginFill(0x000000, 0.7);
                bgMask.graphics.drawRect(0, 0, this.width, this.height);
                bgMask.graphics.endFill();
                bgMask.touchEnabled = true;
                bgMask.addEventListener(egret.TouchEvent.TOUCH_TAP, this.tapSureAction, this);
                this._bgMask = bgMask;
            }
            return this._bgMask;
        },
        enumerable: true,
        configurable: true
    });
    return HelpAlertView;
}(egret.DisplayObjectContainer));
__reflect(HelpAlertView.prototype, "HelpAlertView");
var InitView = (function (_super) {
    __extends(InitView, _super);
    function InitView() {
        var _this = _super.call(this) || this;
        //滚动的字幕数组
        _this.captionPool = [];
        //字幕的数据源
        _this.captionData = [];
        //字幕显示开关
        _this.showCaption = true;
        _this.captionSprite = null;
        _this.initRotation = 0;
        _this.bombMc = null;
        _this.shadowMc = null;
        _this.remainCount = 0;
        _this.currentScore = 0;
        _this.maxRotation = 18;
        //指针
        _this.indicator = null;
        _this.cannon = null;
        _this.kd = null;
        _this.bp = null;
        _this.kp = null;
        _this.scoreText = null;
        _this.countText = null;
        _this.maxText = null;
        _this.leftText = null;
        _this.rightText = null;
        _this.scroll = null;
        _this.luanchComplete = false;
        _this.lastCaptionPosition = 0;
        _this.firstLast = null;
        _this.secondLast = null;
        _this.thirdLast = null;
        _this.initView();
        return _this;
    }
    InitView.prototype.initView = function () {
        return __awaiter(this, void 0, void 0, function () {
            var _this = this;
            var bg, user, rotation, _a, _b;
            return __generator(this, function (_c) {
                switch (_c.label) {
                    case 0:
                        bg = utils.createBitmapByName('bg');
                        bg.width = this.width;
                        bg.height = this.height;
                        this.addChild(bg);
                        return [4 /*yield*/, this.checkUserType()];
                    case 1:
                        user = _c.sent();
                        this.captionSprite = utils.createSprite({
                            width: this.width
                        });
                        this.addChild(this.captionSprite);
                        rotation = Math.random() * this.maxRotation;
                        this.initRotation = Math.random() < 0.5 ? rotation : -rotation;
                        return [4 /*yield*/, this.createBp()];
                    case 2:
                        _c.sent();
                        if (GameData.is_tiyan) {
                            // 游客模式初始化
                            this.guestInit();
                        }
                        else {
                            // 正常情况下初始化
                            this.createSubViews(); //一行三个
                            this.getHome();
                        }
                        //获取字典
                        CurlUtil.curl(config.api_url + '/bxg/config').then(function (data) {
                            if (data.code == 200) {
                                GameData.maxScore = data.data.max_add_score;
                                GameData.personalRank = data.data.personal_rank;
                                GameData.gangRank = data.data.gang_rank;
                                GameData.resetSeed = data.data.top_up_seed;
                                _this.maxText.text = GameData.maxScore + '';
                                _this.luanchComplete = true;
                            }
                            else {
                                Main._parent.addChild(NoticeView.getInstance());
                                NoticeView.getInstance().noticeMsg = "获取字典信息失败!";
                                NoticeView.getInstance().noticetitle = '提示';
                                NoticeView.getInstance().callback = function () {
                                    tvm.closeH5();
                                };
                            }
                        }).catch(function (e) {
                            Main._parent.addChild(NoticeView.getInstance());
                            NoticeView.getInstance().noticeMsg = "网络请求异常!";
                            NoticeView.getInstance().noticetitle = '提示';
                            NoticeView.getInstance().callback = function () {
                                tvm.closeH5();
                            };
                        });
                        _a = this;
                        return [4 /*yield*/, ViewManager.mcManager.play('bomb', 'bomb', 'bomb')];
                    case 3:
                        _a.bombMc = _c.sent();
                        _b = this;
                        return [4 /*yield*/, ViewManager.mcManager.play('shadow', 'shadow', 'shadow')];
                    case 4:
                        _b.shadowMc = _c.sent();
                        this.bombMc.addEventListener(egret.Event.COMPLETE, this.bombComplete, this);
                        this.shadowMc.addEventListener(egret.Event.COMPLETE, this.shadowComplete, this);
                        this.shadowMc.scaleX = 2;
                        this.shadowMc.scaleY = 1.2;
                        return [2 /*return*/];
                }
            });
        });
    };
    // 游客模式初始化
    InitView.prototype.guestInit = function () {
        // 容错处理 
        if (!GameData.is_tiyan)
            return;
        var self = this;
        // 游客模式 分数从缓存中取
        //   this.currentScore = Number(wx.getStorageSync('guestScore')) || 0;
        this.currentScore = Number(utils.getCookie('guestScore')) || 0;
        this.scoreText.text = this.currentScore + '';
        // 游客恢复现场
        CurlUtil.curl(config.api_url + '/bxg/guest_home').then(function (data) {
            if (data['status'] == 'success') {
                data = data['data'];
                GameData.share_reset_count = data['share_reset_count'] || 0;
                GameData.video_reset_count = data['video_reset_count'] || 0;
                // 剩余次数分别从缓存和接口中取 取较大值
                //   var storageRemainCount = Number(wx.getStorageSync('guestRemainCount')) || 0;
                var storageRemainCount = Number(utils.getCookie('guestRemainCount')) || 0;
                var remainCount = data['remain_count'] || 0;
                self.remainCount = Math.min(remainCount, storageRemainCount);
              if (utils.getCookie('guestRemainCount') == undefined || utils.getCookie('guestRemainCount') == ""){
                  self.remainCount = remainCount;
                }
                self.countText.text = self.remainCount + '';
            }
            else {
                GameData.hasBeginning = false;
                self.gameOver();
            }
        });
        // 开始游戏
        this.startGame();
        this.createMonstor('daiji');
    };
    InitView.prototype.getHome = function () {
        var _this = this;
        if (GameData.is_tiyan == true)
            return;
        CurlUtil.curl(config.api_url + '/bxg/home', {}).then(function (data) {
            if (data['status'] == "success") {
                GameData.share_reset_count = data['data']['share_reset_count'];
                GameData.video_reset_count = data['data']['video_reset_count'];
                _this.refreshMyData(data['data']);
                _this.refreshCountDown(data['data']);
            }
            else if (data['code'] == 3001) {
                GameData.hasBeginning = false;
                _this.gameOver();
                _this.showRankView(data);
            }
        });
    };
    InitView.prototype.gameOver = function () {
        var _this = this;
        this.notbegin = utils.createBitmapByName('mupai');
        this.notbegin.width = 369;
        this.notbegin.height = 360;
        this.notbegin.x = this.width / 2 - this.notbegin.width / 2;
        this.notbegin.y = this.height / 2 - this.notbegin.height / 2 + 100;
        this.addChildAt(this.notbegin, this.getChildIndex(this.cannon) - 1);
        if (this.monstorMc && this.contains(this.monstorMc)) {
            this.removeChild(this.monstorMc);
            this.monstorMc.stop();
        }
        //停止游戏
        this.stopGame();
        if (GameData.is_tiyan)
            return;
        CurlUtil.curl(config.api_url + '/bxg/rank/personal/last', {}).then(function (data) {
            if (data.status == 'success') {
                //上期排行揭晓
                if (data.data.list.length <= 0) {
                    Main.showNoEndView();
                }
                else {
                    Main.showLastJFView();
                }
                //上期帮派
                CurlUtil.curl(config.api_url + '/bxg/rank/gang/last', {}).then(function (result) {
                    if (result.status == 'success') {
                        var o = {
                            'personal_rank': data.data.list,
                            'gang_rank': result.data.list,
                        };
                        _this.showRankView(o);
                    }
                });
            }
            else {
                Main._parent.addChild(NoticeView.getInstance());
                NoticeView.getInstance().noticeMsg = "上期排行榜获取失败!【" + data.code + "】";
            }
        }).catch(function (e) {
            Main._parent.addChild(NoticeView.getInstance());
            NoticeView.getInstance().noticeMsg = "接口异常！";
        });
    };
    InitView.prototype.showRankView = function (data) {
        if (this.rankView && this.contains(this.rankView)) {
            this.removeChild(this.rankView);
        }
        this.rankView = new RankView(data);
        this.rankView.width = 218;
        this.rankView.height = this.rankView.width / 218 * 321;
        this.rankView.y = this.propAwardView.y;
        this.rankView.x = GameData.stageW - this.rankView.width - 5;
        this.addChild(this.rankView);
    };
    InitView.prototype.refreshCountDown = function (data) {
        var _this = this;
        this.showRankView(data);
        if (data['start_remain_time']) {
            GameData.hasBeginning = false;
            this.gameOver();
            if (data['start_remain_time'] < 86400) {
                this.showCountDown(data['start_remain_time'], false);
            }
            return;
        }
        if (this.notbegin && this.contains(this.notbegin)) {
            this.removeChild(this.notbegin);
        }
        GameData.hasBeginning = true;
        //获取弹幕
        CurlUtil.curl(config.api_url + '/bxg/barrage', { count: 20 }).then(function (data) {
            if (data.code = 200 && Array.isArray(data.data)) {
                for (var i = 0, len = data.data.length; i < len; i++) {
                    _this.captionData.push(data.data.pop());
                }
            }
        }).catch(function () {
            console.log('调用弹幕接口失败');
        });
        GameData.lefTime = data['remain_time'];
        this.showCountDown(data['remain_time'], true);
        this.createMonstor('daiji');
        //开始游戏
        this.startGame();
    };
    InitView.prototype.showCountDown = function (time, beginning) {
        if (beginning === void 0) { beginning = false; }
        if (!this.countdownView) {
            this.countdownView = new CountDownView();
            this.countdownView.y = this.propAwardView.y + 10;
            this.countdownView.width = 274;
            this.countdownView.height = this.countdownView.width / 274 * 83;
            this.addChild(this.countdownView);
            this.countdownView.x = (this.rankView.x - utils.getMaxX(this.propAwardView) - this.countdownView.width) / 2 + utils.getMaxX(this.propAwardView);
        }
        this.countdownView.refreshTime(time, beginning);
    };
    InitView.prototype.refreshMyData = function (data) {
        if (GameData.is_tiyan) {
            this.countText.visible = false;
            this.scoreText.visible = false;
        }
        else {
            if (data['start_remain_time']) {
                this.countText.text = '';
                this.scoreText.text = '';
            }
            else {
                this.remainCount = data.remain_count || 0;
                this.currentScore = data.score || 0;
                this.countText.text = this.remainCount + '';
                this.scoreText.text = this.currentScore + '';
            }
        }
    };
    InitView.prototype.createSubViews = function () {
        if (!GameData.is_tiyan) {
            this.propAwardView = new PropAwardView();
            this.propAwardView.y = 120;
            this.propAwardView.x = 20;
            this.propAwardView.width = 150;
            this.propAwardView.height = this.propAwardView.width / 150 * 122;
            this.addChild(this.propAwardView);
            this.helpImg = utils.createBitmapByName('help');
            this.helpImg.width = 80;
            this.helpImg.height = 82;
            this.helpImg.x = 55;
            this.helpImg.y = utils.getMaxY(this.propAwardView) + 10;
            this.helpImg.touchEnabled = true;
            this.helpImg.addEventListener(egret.TouchEvent.TOUCH_TAP, this.showHelp, this);
            this.addChild(this.helpImg);
        }
    };
    InitView.prototype.showHelp = function () {
        Main.showHelpView();
    };
    InitView.prototype.createMonstor = function (jsonName, times, score) {
        var _this = this;
        if (times === void 0) { times = -1; }
        if (score === void 0) { score = 0; }
        var self = this;
        return new Promise(function (reslove, reject) { return __awaiter(_this, void 0, void 0, function () {
            var _a;
            return __generator(this, function (_b) {
                switch (_b.label) {
                    case 0:
                        if (self.monstorMc && self.contains(self.monstorMc)) {
                            self.removeChild(self.monstorMc);
                            self.monstorMc.stop();
                        }
                        _a = this;
                        return [4 /*yield*/, ViewManager.mcManager.play(jsonName, jsonName, jsonName)];
                    case 1:
                        _a.monstorMc = _b.sent();
                        this.monstorMc.scaleX = this.monstorMc.scaleY = 1.5;
                        this.monstorMc.x = GameData.stageW / 2 - this.monstorMc.scaleX * 400 / 2;
                        this.monstorMc.y = GameData.stageH / 2 - 230;
                        this.monstorMc.gotoAndPlay(0, times);
                        if (times != -1) {
                            this.monstorMc.once(egret.Event.COMPLETE, reslove, this);
                        }
                        this.addChild(this.monstorMc);
                        this.setChildIndex(this.monstorMc, 2);
                        if (jsonName == 'daiji') {
                            return [2 /*return*/];
                        }
                        this.jifenView = new JifenView(score);
                        this.jifenView.jifenType = jsonName;
                        this.jifenView.width = 375 * 0.9;
                        this.jifenView.height = this.jifenView.width / 375 * 258;
                        this.jifenView.anchorOffsetX = this.jifenView.width / 2;
                        this.jifenView.anchorOffsetY = this.jifenView.height / 2;
                        this.jifenView.x = GameData.stageW / 2;
                        this.jifenView.y = this.monstorMc.y - this.jifenView.height / 2 + 160;
                        this.addChild(this.jifenView);
                        if (jsonName == 'baoji') {
                            this.jifenView.scaleX = 0;
                            this.jifenView.scaleY = 0;
                            egret.Tween.get(this.jifenView).to({ scaleX: 1, scaleY: 1 }, 200, egret.Ease.backOut);
                        }
                        return [2 /*return*/];
                }
            });
        }); });
    };
    InitView.prototype.playBombMc = function () {
        if (this.bombMc) {
            this.bombMc.x = this.indicator.x + (this.indicator.height) * Math.sin(Math.PI / 180 * this.indicator.rotation);
            this.bombMc.y = this.indicator.y - (this.indicator.height) * Math.cos(Math.PI / 180 * this.indicator.rotation);
            this.addChild(this.bombMc);
            this.bombMc.gotoAndPlay(0, 1);
        }
    };
    InitView.prototype.playShadowMc = function () {
        if (this.shadowMc) {
            this.shadowMc.x = this.indicator.x;
            this.shadowMc.y = this.indicator.y;
            this.shadowMc.rotation = this.indicator.rotation;
            this.addChild(this.shadowMc);
            this.addChildAt(this.shadowMc, this.getChildIndex(this.kd) + 1);
            this.shadowMc.gotoAndPlay(0, 1);
        }
    };
    InitView.prototype.bombComplete = function () {
        if (this.contains(this.bombMc)) {
            this.removeChild(this.bombMc);
        }
    };
    InitView.prototype.shadowComplete = function () {
        if (this.contains(this.shadowMc)) {
            this.removeChild(this.shadowMc);
        }
    };
    InitView.prototype.createBp = function () {
        return __awaiter(this, void 0, void 0, function () {
            var bp, mc, kd_bg, scroll, kd, kp, indicator, maxText, leftText, rightText, score_text, count_text;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        bp = utils.createBitmapByName('bp');
                        bp.x = this.width / 2 - bp.width / 2;
                        bp.y = this.height - bp.height;
                        return [4 /*yield*/, ViewManager.mcManager.play('launch', 'launch', 'launch')];
                    case 1:
                        mc = _a.sent();
                        mc.x = GameData.stageW / 2;
                        mc.y = bp.y + 30;
                        this.addChild(mc);
                        //播放完成时停留在第一帧
                        mc.addEventListener(egret.Event.COMPLETE, function () {
                            mc.gotoAndStop(0);
                        }, this);
                        this.cannon = mc;
                        this.setChildIndex(this.cannon, 100);
                        this.addChild(bp);
                        this.bp = bp;
                        kd_bg = utils.createBitmapByName('kd');
                        scroll = new egret.ScrollView();
                        scroll.width = kd_bg.width;
                        scroll.height = kd_bg.height - 10;
                        scroll.anchorOffsetX = scroll.width / 2;
                        scroll.x = this.width / 2;
                        scroll.y = this.height - scroll.height - bp.height * 0.2 - 15;
                        scroll.horizontalScrollPolicy = 'off';
                        scroll.verticalScrollPolicy = 'off';
                        this.addChild(scroll);
                        this.scroll = scroll;
                        scroll.setContent(kd_bg);
                        kd = utils.createBitmapByName('kd_score', { offsetX: 0.5, offsetY: 1 });
                        kd.x = scroll.x;
                        kd.y = scroll.y + kd.height;
                        kd.rotation = this.initRotation;
                        this.kd = kd;
                        this.addChild(kd);
                        kp = utils.createBitmapByName('kp', {
                            offsetX: 0.5,
                            offsetY: 0.5
                        });
                        kp.x = this.width / 2;
                        kp.y = this.height - kp.height / 2;
                        indicator = utils.createBitmapByName('indicator', {
                            offsetX: 0.5,
                            offsetY: 1
                        });
                        indicator.x = scroll.x;
                        indicator.y = kp.y;
                        this.addChild(indicator);
                        this.indicator = indicator;
                        this.addChild(kp);
                        kp.touchAnimation = true;
                        kp.addEventListener(egret.TouchEvent.TOUCH_TAP, this.luanch, this);
                        this.kp = kp;
                        // <begin>
                        if (GameData.is_tiyan) {
                            // 发送消息给开放数据域
                            var platform = window.platform;
                            if (!this.bitmap && !this.contains(this.bitmap)) {
                                this.bitmap = platform.openDataContext.createDisplayObject(null, this.stage.stageWidth, this.stage.stageHeight);
                                this.addChild(this.bitmap);
                            }
                            // 显示排行榜
                            window.platform.openDataContext.postMessage({
                                command: "open"
                            });
                        }
                        // 授权登录
                        var _this = this;
                        wx.getSetting({
                          success(res) {
                            if (res.authSetting['scope.userInfo']) {
                              // 已经授权，可以直接调用
                              _this.checkUserInfo(function(){
                                _this.luanch();
                              });
                            }else{
                              // 未授权 弹出授权框
                              _this.checkUserInfo();
                            }
                          }
                        });
                        // </begin>
                        maxText = utils.createTextField({
                            text: '0',
                            width: 200,
                            size: 22,
                            textColor: 0xFDDC22,
                            bold: true
                        });
                        maxText.anchorOffsetX = maxText.width / 2;
                        maxText.anchorOffsetY = maxText.height / 2;
                        maxText.x = this.width / 2 + (kd.width / 2 - 40) * Math.sin(Math.PI / 180 * this.initRotation);
                        maxText.y = scroll.y + scroll.height - (kd.width / 2 - 40) * Math.cos(Math.PI / 180 * this.initRotation);
                        this.addChild(maxText);
                        this.maxText = maxText;
                        leftText = utils.createTextField({
                            text: '0',
                            size: 22,
                            textColor: 0xFDDC22,
                            bold: true
                        });
                        leftText.anchorOffsetX = leftText.width / 2;
                        leftText.x = scroll.x - scroll.width / 2 + 30;
                        leftText.y = this.height - leftText.height - 68;
                        this.addChild(leftText);
                        this.leftText = leftText;
                        rightText = utils.createTextField({
                            text: '0',
                            size: 22,
                            textColor: 0xFDDC22,
                            bold: true
                        });
                        rightText.anchorOffsetX = rightText.width / 2;
                        rightText.x = scroll.x + scroll.width / 2 - 30;
                        rightText.y = this.height - rightText.height - 68;
                        this.addChild(rightText);
                        this.rightText = rightText;
                        score_text = utils.createTextField({
                            text: '',
                            width: 180,
                            height: 40,
                            size: 28,
                            textColor: 0xFDDC22,
                            bold: true
                        });
                        score_text.x = bp.x + 40;
                        score_text.y = this.height - score_text.height - 20;
                        this.addChild(score_text);
                        this.scoreText = score_text;
                        count_text = utils.createTextField({
                            text: '',
                            width: 180,
                            height: 40,
                            size: 28,
                            textColor: 0xFDDC22,
                            bold: true
                        });
                        count_text.x = bp.x + bp.width - 40 - count_text.width;
                        count_text.y = this.height - count_text.height - 20;
                        this.addChild(count_text);
                        this.countText = count_text;
                        this.stopGame();
                        return [2 /*return*/];
                }
            });
        });
    };
      InitView.prototype.checkUserInfo = function (cb) {
        // 1.微信登录授权
        if (!user_info) {
          var self = this;
          var kp = this.kp;
          if (1) {
            var userInfoBtn = wx.createUserInfoButton({
              type: "text",
              text: "",
              style: {
                left: kp.x / 2 - kp.anchorOffsetX / 2,
                top: kp.y / 2 - kp.anchorOffsetY / 2,
                width: kp.width / 2,
                height: kp.height / 2,
                lineHeight: 40,
                backgroundColor: '',
                color: '#ffffff',
                textAlign: 'center',
                fontSize: 16,
                borderRadius: 4
              }
            });
            userInfoBtn.onTap((res) => {
              try {
                user_info = res.userInfo;
                user_info['nickname'] = res.userInfo['nickName'];
                if (user_info == undefined) {
                  return;
                }
                userInfoBtn.destroy();
                if (cb) cb();
              } catch (err) {
                user_info = undefined;
              }
            });
          }
          return;
        }
      }
    InitView.prototype.changeBpRotation = function () {
        var rotation = Math.random() * this.maxRotation;
        ;
        this.initRotation = Math.random() < 0.5 ? rotation : -rotation;
        this.kd.rotation = this.initRotation;
        this.maxText.x = this.width / 2 + (this.kd.width / 2 - 40) * Math.sin(Math.PI / 180 * this.initRotation);
        this.maxText.y = this.scroll.y + this.scroll.height - (this.kd.width / 2 - 40) * Math.cos(Math.PI / 180 * this.initRotation);
    };
    //指针摆动
    InitView.prototype.rotateIndicator = function () {
        var rotation = this.indicator.rotation;
        var speed = GameData.rotateSpeed / 180;
        var firstTime = (90 - rotation) * speed;
        egret.Tween.get(this.indicator, { loop: true }).to({ rotation: 90 }, firstTime).to({ rotation: -90 }, GameData.rotateSpeed).to({ rotation: rotation }, GameData.rotateSpeed - firstTime);
    };
    //指针停止摆动
    InitView.prototype.stopRotateIndicator = function (homeing) {
        if (homeing === void 0) { homeing = true; }
        egret.Tween.removeTweens(this.indicator);
        if (homeing) {
            this.indicator.rotation = 0;
        }
    };
    /**
     * 发射
     */
    InitView.prototype.luanch = function () {
        var _this = this;
        if (!this.luanchComplete || !GameData.hasBeginning)
            return; //gamedata.hasbeginning 是否在活动中，不在活动中，不能点击
        var self = this;
        if (GameData.is_tiyan) {
            // 1.减次数
            if (this.remainCount-- > 0) {
                this.countText.text = this.remainCount + '';
                this.luanchComplete = false;
                this.stopRotateIndicator(false);
                //指针动画
                this.playBombMc();
                this.playShadowMc();
                //获取开炮结果
                var rotation = this.indicator.rotation;
                if (rotation / this.initRotation) { }
                // 调接口
                utils.checkGuestResult(this.initRotation, rotation).then(function (data) {
                    if (data.code == 200) {
                        self.playLuanchMc(data.b, data.score);
                    }
                }).catch(function (data) {
                    if (data.code == 5004) {
                        Toast.makeText({ text: "您的次数用完了，请明天再来!" }).show();
                        self.countText.text = '0';
                        utils.setCookie('guestRemainCount', self.countText.text);
                        self.restart();
                    }
                    else {
                        Main._parent.addChild(NoticeView.getInstance());
                        NoticeView.getInstance().noticeMsg = "接口异常，请稍后再试!";
                    }
                });
            }
            else {
                // Toast.makeText({ text: "您的次数用完了，请明天再来!" }).show();
                this.resetCount();
            }
        }
        else {
            if (this.remainCount-- > 0) {
                this.countText.text = this.remainCount + '';
                this.luanchComplete = false;
                this.stopRotateIndicator(false);
                //指针动画
                this.playBombMc();
                this.playShadowMc();
                //获取开炮结果
                var rotation_1 = this.indicator.rotation;
                utils.checkResult(this.initRotation, rotation_1).then(function (data) {
                    if (data.code == 200) {
                        _this.playLuanchMc(data.b, data.score);
                        _this.captionData.push({ nickname: user_info.nickname, score: data.score });
                    }
                }).catch(function (data) {
                    if (data.code == 5004) {
                        Toast.makeText({ text: "您的次数用完了，请下期再来!" }).show();
                        self.countText.text = '0';
                        self.restart();
                    }
                    else {
                        Main._parent.addChild(NoticeView.getInstance());
                        NoticeView.getInstance().noticeMsg = "接口异常，请稍后再试!";
                    }
                });
            }
            else {
                this.resetCount();
            }
        }
    };
    /** 重置次数  */
    InitView.prototype.resetCount = function () {
        var type = 1;
        var self = this;
        // 优先看能不能看视频重置 
        if (GameData.video_reset_count > 0) {
            // type = 3;
            if(GameData.share_reset_count > 0){
              type = 2;
            }
        }
        else if (GameData.share_reset_count > 0) {
            type = 2;
        }
        // 如果是游客 并且不能视频重置和分享重置了 那么直接弹提示明天再来
        if (GameData.is_tiyan && type == 1) {
            Toast.makeText({ text: "您的次数用完了，请明天再来!" }).show();
            return;
        }
        Main.showResetView(type).then(function () {
            switch (type) {
                case 1:
                    if (!GameData.is_tiyan) {
                        self.goldhomeRest(type);
                    }
                    else {
                        Toast.makeText({ text: "您还没有种子，请下载电视红包App！" }).show();
                    }
                    break;
                case 2:
                    // <begin> --forWX
                    var titles = config.share_title;
                    var title = titles[Math.floor(Math.random() * titles.length)];
                    // 转发成功 
                    if (!GameData.is_tiyan) {
                      self.goldhomeRest(type);
                    } else {
                      self.guestRest(type);
                    }
                    wx.shareAppMessage({
                        title: title,
                        imageUrl:"http://pic.58pic.com/58pic/15/68/59/71X58PICNjx_1024.jpg",
                        success: function () {
                          console.log('分享-- success');
                        }
                    });
                    // </begin>
                    break;
                case 3:
                    GameData.video_reset_count = 0;
                    // <begin> --forWX
                    // wx.shareAppMessage({
                    //     title: '看视频啊',
                    //     success: function () {
                    //         // 转发成功 
                    //         if (!GameData.is_tiyan) {
                    //             self.goldhomeRest(type);
                    //         } else {
                    //             self.guestRest(type);
                    //         }
                    //     }
                    // });
                    // </begin>
                    break;
            }
            Main.removeResetView();
        }).catch(function () {
            Main.removeResetView();
        });
    };
    /**家园用户重置 */
    InitView.prototype.goldhomeRest = function (type) {
        var self = this;
        CurlUtil.curl(config.api_url + '/bxg/reset', {type:type}).then(function (res) {
            if (res.code == 200) {
                if (type == 2) {
                    GameData.share_reset_count--;
                }
                else if (type == 3) {
                    GameData.video_reset_count--;
                }
                self.remainCount = res.data.max_count;
                self.currentScore = 0;
                self.countText.text = self.remainCount + '';
                self.scoreText.text = self.currentScore + '';
                // Toast.makeText({ text: '重置成功' }).show();
                if(type == 1){
                  Toast.makeText({ text: '重置成功' }).show();
                }
                self.getHome();
            }
            else if (res.code == 604) {
                Toast.makeText({ text: "种子不足" }).show();
            }
            else if (res.code == 605) {
                Toast.makeText({ text: "扣除种子失败" }).show();
            }
            else if(res.code == 9003){
              Toast.makeText({ text: "已重置,请刷新再试!" }).show();
            }
            else {
                Toast.makeText({ text: "重置失败，请稍后再试(code:"+ res.code + ")" }).show();
            }
        }).catch(function () { });
    };
    /**游客重置接口 type 2是分享 3是视频 */
    InitView.prototype.guestRest = function (type) {
        var self = this;
        if (type == 1) {
            return;
        }
        CurlUtil.curl(config.api_url + '/bxg/guest_reset', { type: type }).then(function (res) {
            if (res.code == 200) {
                if (type == 2) {
                    GameData.share_reset_count--;
                }
                else if (type == 3) {
                    GameData.video_reset_count--;
                }
                self.remainCount = res.data.max_count;
                self.currentScore = 0;
                self.countText.text = self.remainCount + '';
                self.scoreText.text = self.currentScore + '';
                // Toast.makeText({ text: '重置成功' }).show();
                // 重置本地数据
                utils.setCookie("guestScore", self.scoreText.text);
                utils.setCookie('guestRemainCount', self.countText.text);
            }
            else { 
                switch (res.code) {
                    case 9006:
                        Toast.makeText({ text: "视频重置机会已用完，请明天再试!" }).show();
                        GameData.video_reset_count = 0;
                        break;
                    default:
                        Toast.makeText({ text: "重置失败，请稍后再试" }).show();
                        break;
                }
            }
        }).catch(function () { });
    };
    //开始游戏
    InitView.prototype.startGame = function () {
        this.kp.texture = RES.getRes('kp');
        this.kp.touchEnabled = true;
        this.bp.texture = RES.getRes('bp');
        this.indicator.visible = true;
        this.maxText.visible = true;
        this.leftText.visible = true;
        this.rightText.visible = true;
        this.kd.visible = true;
        this.rotateIndicator();
    };
    //停止游戏
    InitView.prototype.stopGame = function () {
        this.kp.texture = RES.getRes('kp_black');
        this.kp.touchEnabled = false;
        this.bp.texture = RES.getRes('bp_black');
        this.kd.visible = false;
        this.maxText.visible = false;
        this.leftText.visible = false;
        this.rightText.visible = false;
        this.indicator.visible = false;
        this.scoreText.text = '';
        this.countText.text = '';
        this;
        this.stopRotateIndicator();
    };
    /**
     * 播放发射动画
     */
    InitView.prototype.playLuanchMc = function (isBaoji, score) {
        var _this = this;
        this.cannon.gotoAndPlay(0, 1);
        var jsonName = 'attack';
        if (isBaoji) {
            jsonName = 'baoji';
        }
        setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
            var self;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.createMonstor(jsonName, 1, score)];
                    case 1:
                        _a.sent();
                        self = this;
                        this.currentScore += score;
                        this.scoreText.text = this.currentScore + '';
                        // 游客模式 分数和次数存本地缓存
                        if (GameData.is_tiyan) {
                            utils.setCookie('guestScore', self.scoreText.text);
                            utils.setCookie('guestRemainCount', self.countText.text);
                            // 如果次数用完了 发送到排行榜 并更新排行榜数据
                            if (self.remainCount == 0) {
                                // <begin> --forWX
                                wx.setUserCloudStorage({
                                    KVDataList: [{ key: 'score', value: self.scoreText.text }],
                                    success: res => {
                                        // 让子域更新当前用户的最高分，因为主域无法得到getUserCloadStorage;
                                        // 更新完分数再刷新排行榜
                                        window.platform.openDataContext.postMessage({
                                            command: "update"
                                        });
                                    },
                                    fail: res => {
                                        console.log("fail" + res);
                                    }
                                });
                                // </begin>
                            }
                        }
                        else {
                            this.rankView.refreshRank(this.currentScore);
                        }
                        if (jsonName == 'baoji') {
                            if (this.jifenView && this.contains(this.jifenView)) {
                                egret.Tween.get(this.jifenView).to({ scaleX: 0, scaleY: 0 }, 200, egret.Ease.backIn).call(function () {
                                    this.removeChild(this.jifenView);
                                    this.jifenView = null;
                                    this.restart();
                                }.bind(this));
                            }
                        }
                        else if (jsonName == 'attack') {
                            if (this.jifenView && this.contains(this.jifenView)) {
                                egret.Tween.get(this.jifenView).to({ y: GameData.stageH / 2 - 230 - 258 * 0.9 + 130, alpha: 0 }, 300).call(function () {
                                    this.removeChild(this.jifenView);
                                    this.jifenView = null;
                                }.bind(this));
                                this.restart();
                            }
                        }
                        return [2 /*return*/];
                }
            });
        }); }, 900);
    };
    InitView.prototype.restart = function () {
        if (!GameData.hasBeginning) {
            ViewManager.initView.gameOver();
            return;
        }
        this.createMonstor('daiji');
        this.luanchComplete = true;
        this.changeBpRotation();
        this.rotateIndicator();
        if (this.remainCount <= 0) {
            this.resetCount();
        }
    };
    InitView.prototype.getCaptionItem = function (content, color) {
        var caption = null;
        if (this.captionPool.length > 0) {
            caption = this.captionPool.pop();
        }
        else {
            caption = utils.createTextField({
                size: 28,
                height: 40
            });
        }
        caption.text = content;
        caption.textColor = color;
        return caption;
    };
    InitView.prototype.checkUserType = function () {
        return new Promise(function (reslove, reject) {
            if (true) {
                reslove();
            }
        });
    };
    InitView.prototype.update = function () {
        var _this = this;
        if (this.showCaption && this.captionData.length > 0) {
            var data_1 = this.captionData.shift();
            var content = utils.getChar(data_1.nickname, 30) + '获得了' + data_1.score + '积分';
            var caption_1 = this.getCaptionItem(content, utils.getRandomColor());
            caption_1.y = caption_1.height * this.lastCaptionPosition++;
            if (this.lastCaptionPosition == 1) {
                caption_1.x = this.firstLast ? Math.max(GameData.stageW, this.firstLast.x + this.firstLast.width + 50) : GameData.stageW;
                this.firstLast = caption_1;
            }
            else if (this.lastCaptionPosition == 2) {
                caption_1.x = this.secondLast ? Math.max(GameData.stageW, this.secondLast.x + this.secondLast.width + 50) : GameData.stageW;
                this.secondLast = caption_1;
            }
            else if (this.lastCaptionPosition == 3) {
                caption_1.x = this.thirdLast ? Math.max(GameData.stageW, this.thirdLast.x + this.thirdLast.width + 50) : GameData.stageW;
                this.thirdLast = caption_1;
            }
            this.lastCaptionPosition = this.lastCaptionPosition > 2 ? 0 : this.lastCaptionPosition;
            this.captionSprite.addChild(caption_1);
            egret.Tween.get(caption_1).to({ x: -caption_1.width }, 8000).call(function () {
                _this.captionSprite.removeChild(caption_1);
                _this.captionData.push(data_1);
                _this.captionPool.push(caption_1);
                data_1 = null;
            });
        }
    };
    return InitView;
}(BaseView));
__reflect(InitView.prototype, "InitView");
var JifenView = (function (_super) {
    __extends(JifenView, _super);
    function JifenView(jifen) {
        var _this = _super.call(this) || this;
        _this.type = 'attack';
        _this.jifen = jifen;
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.getViews, _this);
        return _this;
    }
    Object.defineProperty(JifenView.prototype, "jifenType", {
        get: function () {
            return this.type;
        },
        set: function (value) {
            this.type = value;
            if (value == 'baoji') {
                var bg = utils.createBitmapByName("bj_bg");
                bg.width = 375;
                bg.height = bg.width / 375 * 258;
                this.addChild(bg);
                var jifentext = new BaseTextField;
                jifentext.text = '积 分';
                jifentext.size = 40;
                jifentext.bold = true;
                jifentext.textColor = 0xFFF102;
                jifentext.stroke = 5;
                jifentext.strokeColor = 0x6F4702;
                jifentext.rotation = -15;
                jifentext.x = 200;
                jifentext.y = 170;
                this.addChild(jifentext);
                var jifen = new BaseTextField;
                jifen.text = "+" + this.jifen;
                jifen.size = 45;
                jifen.textColor = 0x03FC98;
                jifen.stroke = 5;
                jifen.bold = true;
                jifen.strokeColor = 0x6F4702;
                jifen.rotation = -15;
                jifen.x = 180 - jifen.width / 2;
                jifen.y = 130;
                this.addChild(jifen);
            }
            else if (value == 'attack') {
                var jifen = new BaseTextField;
                jifen.text = "+" + this.jifen;
                jifen.size = 60;
                jifen.textColor = 0xffea22;
                jifen.stroke = 4;
                jifen.bold = true;
                jifen.strokeColor = 0x5a3b0f;
                jifen.x = 180;
                jifen.y = 180;
                this.addChild(jifen);
            }
        },
        enumerable: true,
        configurable: true
    });
    JifenView.prototype.getViews = function () {
    };
    return JifenView;
}(egret.DisplayObjectContainer));
__reflect(JifenView.prototype, "JifenView");
//////////////////////////////////////////////////////////////////////////////////////
//
//  Copyright (c) 2014-present, Egret Technology.
//  All rights reserved.
//  Redistribution and use in source and binary forms, with or without
//  modification, are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//     * Neither the name of the Egret nor the
//       names of its contributors may be used to endorse or promote products
//       derived from this software without specific prior written permission.
//
//  THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
//  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
//  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
//  IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
//  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
//  OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
//  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
//  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
//  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
var LoadingUI = (function (_super) {
    __extends(LoadingUI, _super);
    function LoadingUI() {
        var _this = _super.call(this) || this;
        _this.end = false;
        _this.width = GameData.stageW;
        _this.height = GameData.stageH;
        _this.createView();
        return _this;
    }
    LoadingUI.prototype.createRole = function () {
        var _this = this;
        var movieClipManager = new MovieClipManager();
        var self = this;
        return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
            var role;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        if (!!self._role) return [3 /*break*/, 2];
                        return [4 /*yield*/, movieClipManager.play('loading', 'loading', 'loading')];
                    case 1:
                        role = _a.sent();
                        role.anchorOffsetX = role.width / 2.0;
                        role.anchorOffsetY = role.height / 2.0;
                        role.x = this.width / 2.0;
                        role.y = this.height / 2.0;
                        self._role = role;
                        self.addChild(self._role);
                        _a.label = 2;
                    case 2:
                        resolve(role);
                        return [2 /*return*/];
                }
            });
        }); });
    };
    LoadingUI.prototype.createView = function () {
        var self = this;
        this.createRole().then(function (role) {
            if (!self.end) {
                self._role.gotoAndPlay(0, -1);
            }
        });
    };
    LoadingUI.prototype.onProgress = function (current, total) {
        if (current >= total) {
            if (this._role != undefined)
                this._role.stop();
            this.end = true;
        }
    };
    return LoadingUI;
}(egret.Sprite));
__reflect(LoadingUI.prototype, "LoadingUI", ["RES.PromiseTaskReporter"]);
var NoEndView = (function (_super) {
    __extends(NoEndView, _super);
    function NoEndView() {
        var _this = _super.call(this) || this;
        _this.height = GameData.stageH;
        _this.width = GameData.stageW;
        _this.touchEnabled = true;
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.viewDidLoad, _this);
        return _this;
    }
    NoEndView.prototype.viewDidLoad = function () {
        // 1.幕布
        if (!this.contains(this.bgMask))
            this.addChild(this.bgMask);
        // 2.contentView
        if (!this.contains(this.contentView))
            this.addChild(this.contentView);
        // 3.bg
        if (!this.contentView.contains(this.bg))
            this.contentView.addChild(this.bg);
        // 4.内部背景
        if (!this.contentView.contains(this.bg2))
            this.contentView.addChild(this.bg2);
        // 5.内容
        if (!this.contentView.contains(this.textLabel))
            this.contentView.addChild(this.textLabel);
        // 6. 确定按钮
        if (!this.contentView.contains(this.sureBtn))
            this.contentView.addChild(this.sureBtn);
        // 7. 大标题
        if (!this.contentView.contains(this.titleLabel))
            this.contentView.addChild(this.titleLabel);
        // // 8.X
        // if(!this.contentView.contains(this.cancleBtn)){this.contentView.addChild(this.cancleBtn);}
        // 动画
        this.addAnimation();
    };
    NoEndView.prototype.setCallBack = function (success, cancle) {
        this.successCb = success;
        this.cancleCb = cancle;
    };
    /*********************************************** private **********************************************************/
    NoEndView.prototype.tapSureAction = function () {
        Main.removeNoEndView();
    };
    NoEndView.prototype.removeSelf = function () {
        Main.removeNoEndView();
    };
    NoEndView.prototype.addAnimation = function () {
        this.contentView.scaleX = 0;
        this.contentView.scaleY = 0;
        egret.Tween.removeTweens(this.contentView);
        egret.Tween.get(this.contentView).to({ scaleX: 1.0, scaleY: 1.0 }, 500, egret.Ease.backOut);
    };
    Object.defineProperty(NoEndView.prototype, "textLabel", {
        /*********************************************** getter **********************************************************/
        get: function () {
            if (!this._textLabel) {
                var textLabel = new BaseTextField();
                textLabel.textColor = 0x8F5B12;
                textLabel.lineSpacing = 15;
                textLabel.width = this.bg2.width;
                textLabel.bold = true;
                textLabel.x = this.bg2.x;
                textLabel.text = '上期奖励正在结算...\n稍后再来~';
                textLabel.y = this.bg2.y + 80;
                textLabel.textAlign = egret.HorizontalAlign.CENTER;
                textLabel.size = 36;
                this._textLabel = textLabel;
            }
            return this._textLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NoEndView.prototype, "titleLabel", {
        get: function () {
            if (!this._titleLabel) {
                var titleLabel = new BaseTextField();
                titleLabel.textColor = 0xFFEC79;
                titleLabel.text = "提示";
                titleLabel.stroke = 2;
                titleLabel.width = this.contentView.width;
                titleLabel.y = 40;
                titleLabel.textAlign = egret.HorizontalAlign.CENTER;
                titleLabel.size = 50;
                titleLabel.bold = true;
                titleLabel.strokeColor = 0x6E3E0E;
                this._titleLabel = titleLabel;
            }
            return this._titleLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NoEndView.prototype, "sureBtn", {
        get: function () {
            if (!this._sureBtn) {
                var btn_container = new egret.DisplayObjectContainer();
                var sureBtn = utils.createBitmapByName('know');
                btn_container.addChild(sureBtn);
                btn_container.anchorOffsetX = btn_container.width / 2;
                btn_container.anchorOffsetY = btn_container.height / 2;
                btn_container.x = this.contentView.width / 2;
                btn_container.y = this.bg2.y + this.bg2.height - btn_container.height / 2 - 30;
                btn_container.touchEnabled = true;
                btn_container.addEventListener(egret.TouchEvent.TOUCH_TAP, this.tapSureAction, this);
                this._sureBtn = btn_container;
            }
            return this._sureBtn;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NoEndView.prototype, "bg2", {
        get: function () {
            if (!this._bg2) {
                var bg2 = utils.createBitmapByName('notice_bg', { width: this.contentView.width - 2 * 20 });
                bg2.x = 60;
                bg2.y = 140;
                bg2.scale9Grid = new egret.Rectangle(78, 140, 400, 440);
                bg2.height = this.contentView.height - 240;
                bg2.width = (this.contentView.width - 2 * bg2.x);
                this._bg2 = bg2;
            }
            return this._bg2;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NoEndView.prototype, "bg", {
        get: function () {
            if (!this._bg) {
                var bg = utils.createBitmapByName('friend', { width: this.contentView.width });
                bg.scale9Grid = new egret.Rectangle(0, 146, 600, 91);
                bg.height = this.contentView.height;
                this._bg = bg;
            }
            return this._bg;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NoEndView.prototype, "contentView", {
        get: function () {
            if (!this._contentView) {
                var contentView = new egret.DisplayObjectContainer();
                contentView.touchEnabled = true;
                contentView.width = this.width * 0.95;
                contentView.height = 640;
                contentView.anchorOffsetX = contentView.width / 2.0;
                contentView.anchorOffsetY = contentView.height / 2.0;
                contentView.x = this.width / 2.0;
                contentView.y = this.height / 2.0;
                this._contentView = contentView;
            }
            return this._contentView;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NoEndView.prototype, "bgMask", {
        get: function () {
            if (!this._bgMask) {
                var bgMask = new egret.Shape();
                bgMask.graphics.beginFill(0x000000, 0.7);
                bgMask.graphics.drawRect(0, 0, this.width, this.height);
                bgMask.graphics.endFill();
                this._bgMask = bgMask;
            }
            return this._bgMask;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NoEndView.prototype, "cancleBtn", {
        get: function () {
            if (!this._cancleBtn) {
                var btn = utils.createBitmapByName('x', { offsetX: 0.5, offsetY: 0.5 });
                btn.x = this.contentView.width - 40;
                btn.y = 60;
                btn.touchAnimation = true;
                btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.removeSelf, this);
                this._cancleBtn = btn;
            }
            return this._cancleBtn;
        },
        enumerable: true,
        configurable: true
    });
    return NoEndView;
}(egret.DisplayObjectContainer));
__reflect(NoEndView.prototype, "NoEndView");
var NoticeView = (function (_super) {
    __extends(NoticeView, _super);
    function NoticeView() {
        var _this = _super.call(this) || this;
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.getViews, _this);
        return _this;
    }
    NoticeView.getInstance = function () {
        if (!this.noticeView) {
            this.noticeView = new NoticeView();
        }
        return this.noticeView;
    };
    NoticeView.prototype.getViews = function () {
        var mask = new egret.Shape;
        mask.graphics.beginFill(0x000000, 0.6);
        mask.graphics.drawRect(0, 0, this.width, this.height);
        mask.graphics.endFill();
        mask.touchEnabled = true;
        this.addChild(mask);
        this.bg = utils.createBitmapByName('friend');
        this.bg.scale9Grid = new egret.Rectangle(250, 160, 100, 50);
        this.bg.width = GameData.stageW * 0.9;
        this.bg.height = 400;
        this.bg.x = GameData.stageW * 0.05;
        this.bg.y = GameData.stageH / 2 - this.bg.height / 2;
        this.addChild(this.bg);
        this.noticesprite = new egret.Sprite;
        this.noticesprite.width = this.width * 0.7;
        this.noticesprite.x = this.width / 2 - this.noticesprite.width / 2;
        this.noticesprite.height = this.bg.height;
        this.addChild(this.noticesprite);
        this.noticemsg = new BaseTextField;
        this.noticemsg.textColor = 0xb16f11;
        this.noticemsg.size = 36;
        this.noticemsg.bold = true;
        this.noticemsg.lineSpacing = 10;
        this.noticemsg.textAlign = 'center';
        this.noticemsg.width = this.noticesprite.width;
        this.noticemsg.y = this.bg.y + 150;
        this.noticesprite.addChild(this.noticemsg);
        this.close = utils.createBitmapByName('x');
        this.close.width = 64;
        this.close.height = 72;
        this.close.x = utils.getMaxX(this.bg) - 100;
        this.close.y = this.bg.y + 50;
        this.close.touchEnabled = true;
        this.close.addEventListener(egret.TouchEvent.TOUCH_TAP, this.closeNotice, this);
        this.addChild(this.close);
        this.title = new BaseTextField;
        this.title.text = "提  示";
        this.title.size = 40;
        this.title.bold = true;
        this.title.textColor = 0xffec73;
        this.title.y = this.bg.y + 40;
        this.title.x = this.width / 2 - this.title.width / 2;
        this.title.stroke = 2;
        this.title.strokeColor = 0x6b400b;
        this.addChild(this.title);
    };
    Object.defineProperty(NoticeView.prototype, "noticeMsg", {
        set: function (value) {
            this.noticemsg.text = value;
            this.noticemsg.x = this.noticesprite.width / 2 - this.noticemsg.width / 2;
            this.noticemsg.y = this.bg.y + this.bg.height / 2 - this.noticemsg.height / 2 + 30;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NoticeView.prototype, "noticetitle", {
        set: function (value) {
            this.title.text = value;
            this.title.x = this.width / 2 - this.title.width / 2;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NoticeView.prototype, "callback", {
        set: function (callback) {
            this.noticecallback = callback;
        },
        enumerable: true,
        configurable: true
    });
    NoticeView.prototype.closeNotice = function () {
        if (this.noticecallback) {
            this.noticecallback();
        }
        this.parent.removeChild(this);
    };
    return NoticeView;
}(BaseView));
__reflect(NoticeView.prototype, "NoticeView");
var ViewManager = (function () {
    function ViewManager() {
        this.getViews();
    }
    ViewManager.prototype.getViews = function () {
        this.startGame();
    };
    ViewManager.prototype.startGame = function () {
        egret.ImageLoader.crossOrigin = "anonymous";
        ViewManager.mcManager = new MovieClipManager();
    };
    ViewManager.initView = null;
    //奖励道具
    ViewManager.rewardView = null;
    //积分排行榜弹窗
    ViewManager.jfView = null;
    // 上期积分排行榜弹窗
    ViewManager.lastJFView = null;
    // 帮助
    ViewManager.helpView = null;
    ViewManager.mcManager = null;
    ViewManager.resetView = null;
    ViewManager.top3View = null;
    ViewManager.toolInfoView = null;
    ViewManager.noEndView = null;
    return ViewManager;
}());
__reflect(ViewManager.prototype, "ViewManager");
var RankView = (function (_super) {
    __extends(RankView, _super);
    function RankView(data) {
        var _this = _super.call(this) || this;
        _this.rankData = data;
        _this.personalRanks = data['personal_rank'];
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.getViews, _this);
        _this.touchEnabled = true;
        _this.addEventListener(egret.TouchEvent.TOUCH_TAP, _this.showRank, _this);
        return _this;
    }
    RankView.prototype.initGangRank = function () {
        if (this.rankData['gang_rank']) {
            if (this.rankData['gang_rank'].length > 0) {
                this.gangFirst = new RankTextField();
                this.gangFirst.text = utils.getChar(this.rankData['gang_rank'][0]['gang_name'], 15);
                this.gangFirst.x = 95;
                this.gangFirst.y = 155 + 25;
                this.addChild(this.gangFirst);
            }
            if (this.rankData['gang_rank'].length > 1) {
                this.gangSecond = new RankTextField();
                this.gangSecond.text = utils.getChar(this.rankData['gang_rank'][1]['gang_name'], 15);
                this.gangSecond.x = this.gangFirst.x;
                this.gangSecond.y = utils.getMaxY(this.gangFirst) + 15;
                this.addChild(this.gangSecond);
            }
            if (this.rankData['gang_rank'].length > 2) {
                this.gangThird = new RankTextField();
                this.gangThird.text = utils.getChar(this.rankData['gang_rank'][2]['gang_name'], 15);
                this.gangThird.x = this.gangFirst.x;
                this.gangThird.y = utils.getMaxY(this.gangSecond) + 15;
                this.addChild(this.gangThird);
            }
        }
    };
    RankView.prototype.getViews = function () {
        var bg = utils.createBitmapByName('rank');
        bg.width = this.width;
        bg.height = this.height;
        this.addChild(bg);
        if (this.rankData['start_remain_time']) {
            return;
        }
        this.personalFirst = new RankTextField();
        if (this.personalRanks && this.personalRanks.length > 0) {
            this.personalFirst.text = utils.getChar(this.personalRanks[0]['nickname'], 15);
        }
        else {
            this.personalFirst.text = utils.getChar('', 15);
        }
        this.personalFirst.x = 95;
        this.personalFirst.y = 64;
        this.addChild(this.personalFirst);
        this.personalSecond = new RankTextField();
        if (this.personalRanks && this.personalRanks.length > 1) {
            this.personalSecond.text = utils.getChar(this.personalRanks[1]['nickname'], 15);
        }
        else {
            this.personalSecond.text = utils.getChar('', 15);
        }
        this.personalSecond.x = this.personalFirst.x;
        this.personalSecond.y = utils.getMaxY(this.personalFirst) + 15;
        this.addChild(this.personalSecond);
        this.personalThird = new RankTextField();
        if (this.personalRanks && this.personalRanks.length > 2) {
            this.personalThird.text = utils.getChar(this.personalRanks[2]['nickname'], 15);
        }
        else {
            this.personalThird.text = utils.getChar('', 15);
        }
        this.personalThird.x = this.personalFirst.x;
        this.personalThird.y = utils.getMaxY(this.personalSecond) + 15;
        this.addChild(this.personalThird);
        this.initGangRank();
    };
    RankView.prototype.showRank = function () {
        if (GameData.hasBeginning) {
            Main.showJFView(GameData.lefTime);
        }
        else {
            Main.showLastJFView();
        }
    };
    RankView.prototype.compare = function (property) {
        return function (a, b) {
            var value1 = a[property];
            var value2 = b[property];
            return value2 - value1;
        };
    };
    RankView.prototype.removeDuplicatedItem = function (ar) {
        var ret = [];
        for (var i = 0, j = ar.length; i < j; i++) {
            var has = false;
            for (var k in ret) {
                if (ret[k]['tvmid'] == ar[i]['tvmid']) {
                    has = true;
                }
            }
            if (!has) {
                ret.push(ar[i]);
            }
        }
        return ret;
    };
    RankView.prototype.refreshRank = function (myScore) {
        var tempRank = {};
        tempRank['tvmid'] = utils.getCookie('tvmid');
        tempRank['nickname'] = user_info['nickname'];
        tempRank['total_score'] = myScore;
        this.personalRanks.push(tempRank);
        this.personalRanks.sort(this.compare('total_score')); //数组首先排序
        this.personalRanks = this.removeDuplicatedItem(this.personalRanks); //数组去重
        if (this.personalRanks.length > 0) {
            this.personalFirst.text = utils.getChar(this.personalRanks[0]['nickname'], 15);
        }
        if (this.personalRanks.length > 1) {
            this.personalSecond.text = utils.getChar(this.personalRanks[1]['nickname'], 15);
        }
        if (this.personalRanks.length > 2) {
            this.personalThird.text = utils.getChar(this.personalRanks[2]['nickname'], 15);
        }
    };
    return RankView;
}(egret.DisplayObjectContainer));
__reflect(RankView.prototype, "RankView");
var RankTextField = (function (_super) {
    __extends(RankTextField, _super);
    function RankTextField() {
        var _this = _super.call(this) || this;
        _this.fontFamily = '微软雅黑';
        _this.size = 20;
        _this.textColor = 0xffea22;
        _this.stroke = 2;
        _this.strokeColor = 0x5a3b0f;
        return _this;
    }
    return RankTextField;
}(BaseTextField));
__reflect(RankTextField.prototype, "RankTextField");
var ResetAlertView = (function (_super) {
    __extends(ResetAlertView, _super);
    function ResetAlertView() {
        var _this = _super.call(this) || this;
        _this.type = 1; // 重置类型 1是种子重置 2是分享重置 3是看视频重置
        _this.height = GameData.stageH;
        _this.width = GameData.stageW;
        _this.touchEnabled = true;
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.viewDidLoad, _this);
        return _this;
    }
    ResetAlertView.prototype.viewDidLoad = function () {
        // 1.幕布
        if (!this.contains(this.bgMask))
            this.addChild(this.bgMask);
        // 2.contentView
        if (!this.contains(this.contentView))
            this.addChild(this.contentView);
        // 3.bg
        if (!this.contentView.contains(this.bg))
            this.contentView.addChild(this.bg);
        // 4.内部背景
        if (!this.contentView.contains(this.bg2))
            this.contentView.addChild(this.bg2);
        // 5.内容
        if (!this.contentView.contains(this.textLabel))
            this.contentView.addChild(this.textLabel);
        // 7. 大标题
        if (!this.contentView.contains(this.titleLabel))
            this.contentView.addChild(this.titleLabel);
        // 8.X
        if (!this.contentView.contains(this.cancleBtn)) {
            this.contentView.addChild(this.cancleBtn);
        }
        // 根据类型 添加按钮
        this.addSureBtn();
        // 动画
        this.addAnimation();
    };
    ResetAlertView.prototype.addSureBtn = function () {
        switch (this.type) {
            case 1:
                this.getTypeBtn(this.sureBtn);
                break;
            case 2:
                this.getTypeBtn(this.shareSureBtn);
                break;
            case 3:
                this.getTypeBtn(this.videoSureBtn);
                break;
        }
    };
    ResetAlertView.prototype.getTypeBtn = function (obj) {
        if (this.contentView.contains(this.sureBtn))
            this.contentView.removeChild(this.sureBtn);
        if (this.contentView.contains(this.videoSureBtn))
            this.contentView.removeChild(this.videoSureBtn);
        if (this.contentView.contains(this.shareSureBtn))
            this.contentView.removeChild(this.shareSureBtn);
        this.contentView.addChild(obj);
    };
    ResetAlertView.prototype.setCallBack = function (success, cancle) {
        this.successCb = success;
        this.cancleCb = cancle;
    };
    /*********************************************** private **********************************************************/
    ResetAlertView.prototype.tapSureAction = function () {
        if (this.successCb) {
            this.successCb();
        }
    };
    ResetAlertView.prototype.removeSelf = function () {
        if (this.cancleCb) {
            this.cancleCb();
        }
    };
    ResetAlertView.prototype.addAnimation = function () {
        this.contentView.scaleX = 0;
        this.contentView.scaleY = 0;
        egret.Tween.removeTweens(this.contentView);
        egret.Tween.get(this.contentView).to({ scaleX: 1.0, scaleY: 1.0 }, 500, egret.Ease.backOut);
    };
    Object.defineProperty(ResetAlertView.prototype, "textLabel", {
        /*********************************************** getter **********************************************************/
        get: function () {
            if (!this._textLabel) {
                var textLabel = new BaseTextField();
                textLabel.textColor = 0x8F5B12;
                textLabel.lineSpacing = 15;
                textLabel.width = this.bg2.width;
                textLabel.bold = true;
                textLabel.x = this.bg2.x;
                textLabel.text = '您的次数已经用完了\n打的不爽？';
                textLabel.y = this.bg2.y + 80;
                textLabel.textAlign = egret.HorizontalAlign.CENTER;
                textLabel.size = 36;
                this._textLabel = textLabel;
            }
            return this._textLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ResetAlertView.prototype, "titleLabel", {
        get: function () {
            if (!this._titleLabel) {
                var titleLabel = new BaseTextField();
                titleLabel.textColor = 0xFFEC79;
                titleLabel.text = "提示";
                titleLabel.stroke = 2;
                titleLabel.width = this.contentView.width;
                titleLabel.y = 40;
                titleLabel.textAlign = egret.HorizontalAlign.CENTER;
                titleLabel.size = 50;
                titleLabel.bold = true;
                titleLabel.strokeColor = 0x6E3E0E;
                this._titleLabel = titleLabel;
            }
            return this._titleLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ResetAlertView.prototype, "sureBtn", {
        get: function () {
            if (!this._sureBtn) {
                var btn_container = new egret.DisplayObjectContainer();
                var sureBtn = utils.createBitmapByName('btn_set');
                btn_container.addChild(sureBtn);
                var seed = utils.createBitmapByName('seed');
                var seedNum = utils.createTextField({
                    text: '' + GameData.resetSeed,
                    textColor: 0xFBE005,
                    stroke: 2,
                    strokeColor: 0x8F5B12,
                    size: 30,
                    height: btn_container.height,
                });
                var reset = utils.createTextField({
                    text: '重打一次',
                    textColor: 0xFFFFFF,
                    stroke: 2,
                    strokeColor: 0x8F5B12,
                    size: 28,
                    height: btn_container.height,
                });
                seed.x = btn_container.width / 2 - (seed.width + seedNum.width + reset.width + 20) / 2;
                seed.y = btn_container.height / 2 - seed.height / 2;
                seedNum.x = seed.x + seed.width + 10;
                reset.x = seedNum.x + seedNum.width + 10;
                btn_container.addChild(seed);
                btn_container.addChild(seedNum);
                btn_container.addChild(reset);
                btn_container.anchorOffsetX = btn_container.width / 2;
                btn_container.anchorOffsetY = btn_container.height / 2;
                btn_container.x = this.contentView.width / 2;
                btn_container.y = this.bg2.y + this.bg2.height - btn_container.height / 2 - 30;
                btn_container.touchEnabled = true;
                btn_container.addEventListener(egret.TouchEvent.TOUCH_TAP, this.tapSureAction, this);
                this._sureBtn = btn_container;
            }
            return this._sureBtn;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ResetAlertView.prototype, "videoSureBtn", {
        get: function () {
            if (!this._videoSureBtn) {
                var btn_container = new egret.DisplayObjectContainer();
                var sureBtn = utils.createBitmapByName('btn_set');
                btn_container.addChild(sureBtn);
                var player = utils.createBitmapByName('player_icon_png');
                var reset = utils.createTextField({
                    text: '重打一次',
                    textColor: 0xFFFFFF,
                    stroke: 2,
                    strokeColor: 0x8F5B12,
                    size: 28,
                    height: btn_container.height - 4,
                });
                player.x = btn_container.width / 2 - (player.width + reset.width + 20) / 2;
                player.y = btn_container.height / 2 - player.height / 2 - 4;
                reset.x = player.x + player.width + 20;
                btn_container.addChild(player);
                btn_container.addChild(reset);
                btn_container.anchorOffsetX = btn_container.width / 2;
                btn_container.anchorOffsetY = btn_container.height / 2;
                btn_container.x = this.contentView.width / 2;
                btn_container.y = this.bg2.y + this.bg2.height - btn_container.height / 2 - 30;
                btn_container.touchEnabled = true;
                btn_container.addEventListener(egret.TouchEvent.TOUCH_TAP, this.tapSureAction, this);
                this._videoSureBtn = btn_container;
            }
            return this._videoSureBtn;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ResetAlertView.prototype, "shareSureBtn", {
        get: function () {
            if (!this._shareSureBtn) {
                var btn_container = new egret.DisplayObjectContainer();
                var sureBtn = utils.createBitmapByName('btn_set_g_png');
                btn_container.addChild(sureBtn);
                var reset = utils.createTextField({
                    text: '分享重打一次',
                    textColor: 0xFFFFFF,
                    stroke: 2,
                    strokeColor: 0x284E00,
                    size: 28,
                    height: btn_container.height - 4,
                });
                reset.width = btn_container.width;
                btn_container.addChild(reset);
                btn_container.anchorOffsetX = btn_container.width / 2;
                btn_container.anchorOffsetY = btn_container.height / 2;
                btn_container.x = this.contentView.width / 2;
                btn_container.y = this.bg2.y + this.bg2.height - btn_container.height / 2 - 30;
                btn_container.touchEnabled = true;
                btn_container.addEventListener(egret.TouchEvent.TOUCH_TAP, this.tapSureAction, this);
                this._shareSureBtn = btn_container;
            }
            return this._shareSureBtn;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ResetAlertView.prototype, "bg2", {
        get: function () {
            if (!this._bg2) {
                var bg2 = utils.createBitmapByName('notice_bg', { width: this.contentView.width - 2 * 20 });
                bg2.x = 60;
                bg2.y = 140;
                bg2.scale9Grid = new egret.Rectangle(78, 140, 400, 440);
                bg2.height = this.contentView.height - 240;
                bg2.width = (this.contentView.width - 2 * bg2.x);
                this._bg2 = bg2;
            }
            return this._bg2;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ResetAlertView.prototype, "bg", {
        get: function () {
            if (!this._bg) {
                var bg = utils.createBitmapByName('friend', { width: this.contentView.width });
                bg.scale9Grid = new egret.Rectangle(0, 146, 600, 91);
                bg.height = this.contentView.height;
                this._bg = bg;
            }
            return this._bg;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ResetAlertView.prototype, "contentView", {
        get: function () {
            if (!this._contentView) {
                var contentView = new egret.DisplayObjectContainer();
                contentView.touchEnabled = true;
                contentView.width = this.width * 0.95;
                contentView.height = 640;
                contentView.anchorOffsetX = contentView.width / 2.0;
                contentView.anchorOffsetY = contentView.height / 2.0;
                contentView.x = this.width / 2.0;
                contentView.y = this.height / 2.0;
                this._contentView = contentView;
            }
            return this._contentView;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ResetAlertView.prototype, "bgMask", {
        get: function () {
            if (!this._bgMask) {
                var bgMask = new egret.Shape();
                bgMask.graphics.beginFill(0x000000, 0.7);
                bgMask.graphics.drawRect(0, 0, this.width, this.height);
                bgMask.graphics.endFill();
                this._bgMask = bgMask;
            }
            return this._bgMask;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ResetAlertView.prototype, "cancleBtn", {
        get: function () {
            if (!this._cancleBtn) {
                var btn = utils.createBitmapByName('x', { offsetX: 0.5, offsetY: 0.5 });
                btn.x = this.contentView.width - 40;
                btn.y = 60;
                btn.touchAnimation = true;
                btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.removeSelf, this);
                this._cancleBtn = btn;
            }
            return this._cancleBtn;
        },
        enumerable: true,
        configurable: true
    });
    return ResetAlertView;
}(egret.DisplayObjectContainer));
__reflect(ResetAlertView.prototype, "ResetAlertView");
var ToolInfoView = (function (_super) {
    __extends(ToolInfoView, _super);
    function ToolInfoView() {
        var _this = _super.call(this) || this;
        _this.data = {};
        _this.maskAlpha = 0;
        _this.width = GameData.stageW;
        _this.height = GameData.stageH;
        return _this;
    }
    ToolInfoView.prototype.open = function (data) {
        this.data = data;
        if (!this.contains(this.bgMask)) {
            this.addChild(this.bgMask);
        }
        // 内容容器
        if (!this.contains(this.contentView)) {
            this.addChild(this.contentView);
        }
        if (!this.contentView.contains(this.contentviewbg)) {
            this.contentView.addChild(this.contentviewbg);
            this.contentView.setChildIndex(this.contentviewbg, 0);
        }
        // 关闭按钮
        if (!this.contentView.contains(this.closeBtn)) {
            this.contentView.addChild(this.closeBtn);
        }
        if (!this.contentView.contains(this.contentviewtitle)) {
            this.contentView.addChild(this.contentviewtitle);
        }
        this._contentviewtitle.text = data.type == 1 ? '道具信息' : data.name;
        if (data.type == 1) {
            if (!this.contentView.contains(this.toolImage)) {
                this.contentView.addChild(this.toolImage);
            }
            this._toolImage.source = data.img;
            this._toolImage.x = (this.contentviewbg.width - this.toolImage.width) / 2;
            if (this.contentView.contains(this.toolImage2)) {
                this.contentView.removeChild(this.toolImage2);
            }
            if (this.contentView.contains(this.arrow)) {
                this.contentView.removeChild(this.arrow);
            }
            if (this.contentView.contains(this.arrowtest)) {
                this.contentView.removeChild(this.arrowtest);
            }
            if (!this.contentView.contains(this.toolName)) {
                this.contentView.addChild(this.toolName);
            }
            this._toolName.text = data.name;
            this._toolName.x = (this.contentviewbg.width - this.toolName.width) / 2;
        }
        else {
            if (!this.contentView.contains(this.toolImage)) {
                this.contentView.addChild(this.toolImage);
            }
            this._toolImage.source = data.img;
            this._toolImage.x = 80;
            if (!this.contentView.contains(this.toolImage2)) {
                this.contentView.addChild(this.toolImage2);
            }
            this._toolImage2.source = data.parent_img;
            this._toolImage2.x = this.contentView.width - 215;
            if (!this.contentView.contains(this.arrow)) {
                this.contentView.addChild(this.arrow);
            }
            if (!this.contentView.contains(this.arrowtest)) {
                this.contentView.addChild(this.arrowtest);
            }
            if (this.contentView.contains(this.toolName)) {
                this.contentView.removeChild(this.toolName);
            }
        }
        if (!this.contentView.contains(this.toolContent)) {
            this.contentView.addChild(this.toolContent);
        }
        if (data.type == 1) {
            this._toolContent.text = data.desc;
        }
        else {
            this._toolContent.text = data.parent_name + '-' + data.parent_desc;
        }
        // 添加动画
        this.addBaseAnimation();
    };
    ToolInfoView.prototype.addBaseAnimation = function () {
        this.contentView.scaleX = 0.8;
        this.contentView.scaleY = 0.8;
        var tw = egret.Tween.get(this.contentView);
        tw.to({ scaleX: 1, scaleY: 1 }, 500, egret.Ease.backOut);
    };
    Object.defineProperty(ToolInfoView.prototype, "contentView", {
        get: function () {
            if (!this._contentView) {
                var contentView = new egret.DisplayObjectContainer();
                contentView.width = 690 * 0.88;
                contentView.height = 600 * 0.88;
                contentView.anchorOffsetX = contentView.width / 2;
                contentView.anchorOffsetY = contentView.height / 2;
                contentView.x = this.width / 2.0;
                contentView.y = this.height / 2.0;
                this._contentView = contentView;
            }
            return this._contentView;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ToolInfoView.prototype, "bgMask", {
        get: function () {
            if (!this._bgMask) {
                var bgMask = new egret.Shape();
                bgMask.graphics.beginFill(0x000000, this.maskAlpha);
                bgMask.graphics.drawRect(0, 0, this.width, this.height);
                bgMask.graphics.endFill();
                bgMask.touchEnabled = true;
                this._bgMask = bgMask;
            }
            return this._bgMask;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ToolInfoView.prototype, "contentviewbg", {
        get: function () {
            // console.log(this._contentviewbg);
            if (!this._contentviewbg) {
                var contentviewbg = utils.createBitmapByName('dj_tk');
                contentviewbg.height = this.contentView.height;
                contentviewbg.width = this.contentView.width;
                this._contentviewbg = contentviewbg;
            }
            return this._contentviewbg;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ToolInfoView.prototype, "closeBtn", {
        get: function () {
            if (!this._close) {
                var close = utils.createBitmapByName("sure");
                close.anchorOffsetX = close.width / 2;
                close.x = this.contentView.width / 2;
                close.y = this.contentView.height - close.height * 1.25;
                close.touchAnimation = true;
                close.addEventListener(egret.TouchEvent.TOUCH_TAP, this.closeAction, this);
                this._close = close;
            }
            return this._close;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ToolInfoView.prototype, "contentviewtitle", {
        get: function () {
            if (!this._contentviewtitle) {
                var title = new BaseTextField();
                title.text = '';
                title.size = 25;
                title.textColor = 0xffffff;
                title.stroke = 2;
                title.strokeColor = 0x663E0D;
                title.width = this.contentView.width;
                title.height = 40;
                title.textAlign = egret.HorizontalAlign.CENTER;
                title.verticalAlign = egret.VerticalAlign.MIDDLE;
                this._contentviewtitle = title;
            }
            return this._contentviewtitle;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ToolInfoView.prototype, "toolImage", {
        get: function () {
            if (!this._toolImage) {
                var image = new eui.Image();
                image.width = 135;
                image.height = 135;
                image.y = 75;
                this._toolImage = image;
            }
            return this._toolImage;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ToolInfoView.prototype, "toolImage2", {
        get: function () {
            if (!this._toolImage2) {
                var image = new eui.Image();
                image.width = 135;
                image.height = 135;
                image.y = 75;
                this._toolImage2 = image;
            }
            return this._toolImage2;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ToolInfoView.prototype, "arrow", {
        get: function () {
            if (!this._arrow) {
                var image = utils.createBitmapByName("dj_arrow");
                image.width = 114;
                image.height = 70;
                image.y = 100;
                image.x = (this.contentView.width - image.width) / 2;
                this._arrow = image;
            }
            return this._arrow;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ToolInfoView.prototype, "arrowtest", {
        get: function () {
            if (!this._arrowtest) {
                var title = new BaseTextField();
                title.text = '1,2,3,4可合成';
                title.size = 20;
                title.textColor = 0xfde157;
                title.stroke = 2;
                title.strokeColor = 0x663E0D;
                title.height = 40;
                title.verticalAlign = egret.VerticalAlign.TOP;
                title.y = 180;
                title.x = (this.contentView.width - title.width) / 2;
                title.bold = true;
                this._arrowtest = title;
            }
            return this._arrowtest;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ToolInfoView.prototype, "toolName", {
        get: function () {
            if (!this._toolName) {
                var title = new BaseTextField();
                title.text = '';
                title.size = 24;
                title.textColor = 0xfde157;
                title.stroke = 2;
                title.strokeColor = 0x663E0D;
                title.height = 40;
                title.verticalAlign = egret.VerticalAlign.TOP;
                title.y = 230;
                title.bold = true;
                this._toolName = title;
            }
            return this._toolName;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ToolInfoView.prototype, "toolContent", {
        get: function () {
            if (!this._toolContent) {
                var shape = new egret.Shape();
                shape.width = this.contentviewbg.width - 50;
                shape.height = 30 + 30 * Math.ceil(this.data['desc'].length / 10);
                if (shape.height < 90) {
                    shape.height = 90;
                }
                if (shape.height > 90) {
                    this.toolImage2.y = this.toolImage.y = this.toolImage.y + 15;
                }
                shape.graphics.beginFill(0x70511A);
                shape.graphics.drawRoundRect(0, 0, shape.width, shape.height, 30, 30);
                shape.graphics.endFill;
                shape.x = 25;
                shape.y = 270;
                this.contentView.addChild(shape);
                var title = new BaseTextField();
                title.text = '';
                title.size = 24;
                title.textColor = 0xfde157;
                title.stroke = 2;
                title.strokeColor = 0x663E0D;
                title.height = shape.height - 20;
                title.width = shape.width - 20;
                title.x = shape.x + 10;
                title.y = shape.y + 10;
                title.lineSpacing = 15;
                title.textAlign = egret.HorizontalAlign.CENTER;
                title.verticalAlign = egret.VerticalAlign.MIDDLE;
                this._toolContent = title;
            }
            return this._toolContent;
        },
        enumerable: true,
        configurable: true
    });
    ToolInfoView.prototype.closeAction = function (event) {
        Main.removeTooInfoView();
    };
    return ToolInfoView;
}(egret.Sprite));
__reflect(ToolInfoView.prototype, "ToolInfoView");
var RankItem = (function (_super) {
    __extends(RankItem, _super);
    function RankItem(index) {
        var _this = _super.call(this) || this;
        var icon = null;
        if (index <= 3) {
            icon = utils.createBitmapByName(index + '');
        }
        else {
            icon = utils.createTextField({
                width: 50,
                height: 30,
                size: 27,
                textColor: 0xF3F010,
                text: index + ''
            });
        }
        _this.addChild(icon);
        var rank_text = utils.createTextField({
            text: '第' + _this.getChinese(index) + '名',
            height: icon.height,
            x: icon.width + 10,
            textColor: 0xFFC71F,
            stroke: 2,
            strokeColor: 0x541C09,
            size: 22
        });
        _this.addChild(rank_text);
        return _this;
    }
    RankItem.prototype.getChinese = function (index) {
        switch (index) {
            case 1:
                return '一';
            case 2:
                return '二';
            case 3:
                return '三';
            case 4:
                return '四';
            case 5:
                return '五';
            case 6:
                return '六';
            case 7:
                return '七';
            case 8:
                return '八';
            case 9:
                return '九';
            case 10:
                return '十';
            default:
                return '';
        }
    };
    return RankItem;
}(egret.Sprite));
__reflect(RankItem.prototype, "RankItem");
var tr = egret.sys.tr;
var RewardItem = (function (_super) {
    __extends(RewardItem, _super);
    function RewardItem(item) {
        var _this = _super.call(this) || this;
        _this.width = GameData.stageW * 0.6;
        _this.height = 105;
        //边框
        var border = utils.createBitmapByName('dj_bg');
        border.width = 90;
        border.height = 90;
        border.anchorOffsetX = border.width / 2;
        border.anchorOffsetY = border.height / 2;
        border.x = border.width / 2;
        border.y = _this.height / 2;
        _this.height / 2;
        _this.addChild(border);
        var img = new eui.Image();
        img.width = border.width * 0.85;
        img.height = border.height * 0.85;
        img.anchorOffsetX = img.width / 2;
        img.anchorOffsetY = img.height / 2;
        img.y = _this.height / 2;
        img.x = border.x;
        img.source = item.prop_img;
        _this.addChild(img);
        var name = utils.createTextField({
            text: item.prop_name,
            textColor: 0xFFFFFF,
            size: 24,
            height: _this.height / 2,
            x: img.width / 2 + img.x + 30,
        });
        _this.addChild(name);
        var count = utils.createTextField({
            text: 'X' + item.count,
            textColor: 0xFFC71F,
            height: _this.height / 2,
            x: name.width + name.x + 5,
        });
        _this.addChild(count);
        var content = utils.createTextField({
            text: item.prop_desc,
            textColor: 0xFFFFFF,
            size: 21,
            lineSpacing: 18,
            textAlign: egret.HorizontalAlign.LEFT
        });
        if (content.width > _this.width * 0.8) {
            content.width = _this.width * 0.8;
        }
        content.x = name.x;
        content.y = _this.height / 2;
        var shape = new egret.Shape();
        shape.width = content.width + 20;
        shape.height = content.height + 20;
        shape.graphics.beginFill(0x000000);
        shape.graphics.drawRoundRect(0, 0, shape.width, shape.height, 20, 20);
        shape.graphics.endFill();
        shape.x = content.x - 10;
        shape.y = content.y - 10;
        _this.addChild(shape);
        _this.addChild(content);
        if (content.height > _this.height / 2) {
            _this.height += (shape.height - _this.height / 2);
        }
        _this.cacheAsBitmap = true;
        return _this;
    }
    return RewardItem;
}(egret.Sprite));
__reflect(RewardItem.prototype, "RewardItem");
var RewardView = (function (_super) {
    __extends(RewardView, _super);
    function RewardView() {
        var _this = _super.call(this) || this;
        _this.hasSet = false;
        _this.personalTab = null;
        _this.gangTab = null;
        _this.containerView = null;
        _this.contentView = null;
        _this.scroller = null;
        _this.gangScroller = null;
        //窗口最大高度
        _this.maxHeight = GameData.stageH * 0.8;
        _this.initView();
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.addToStage, _this);
        return _this;
    }
    RewardView.prototype.addToStage = function () {
        if (GameData.personalRank) {
            if (!this.hasSet) {
                this.hasSet = true;
                this.setContentView(GameData.personalRank, GameData.gangRank);
            }
            this.addAnimation();
        }
        else {
            Main.removeRewardView();
        }
        ;
    };
    RewardView.prototype.initView = function () {
        var bgMask = new egret.Shape();
        bgMask.width = this.width;
        bgMask.height = this.height;
        bgMask.graphics.beginFill(0x000000, 0.6);
        bgMask.graphics.drawRect(0, 0, this.width, this.height);
        bgMask.graphics.endFill();
        this.addChild(bgMask);
        bgMask.touchEnabled = true;
    };
    RewardView.prototype.setContentView = function (data, data2) {
        data.sort(function (item1, item2) {
            if (item1.rank > item2.rank) {
                return 1;
            }
            return -1;
        });
        data2.sort(function (item1, item2) {
            if (item1.rank > item2.rank) {
                return 1;
            }
            return -1;
        });
        this.containerView = utils.createSprite({
            width: GameData.stageW * 0.77,
            height: GameData.stageH * 0.7,
            offsetX: 0.5,
            offsetY: 0.5,
            x: GameData.stageW / 2,
            y: GameData.stageH / 2
        });
        this.addChild(this.containerView);
        var bg = utils.createBitmapByName('jldj_bg');
        bg.width = this.containerView.width;
        bg.height = this.containerView.height;
        this.containerView.addChild(bg);
        var title = utils.createBitmapByName('jldjpng');
        title.x = this.containerView.width / 2 - title.width / 2;
        title.y = -title.height / 2;
        this.containerView.addChild(title);
        var tab1 = new TabItem({
            content: '个人奖励'
        });
        tab1.addEventListener(egret.TouchEvent.TOUCH_TAP, this.changePersonal, this);
        tab1.changeSelected(true);
        this.personalTab = tab1;
        var tab2 = new TabItem({
            content: '帮会奖励'
        });
        tab2.addEventListener(egret.TouchEvent.TOUCH_TAP, this.changeGang, this);
        this.gangTab = tab2;
        tab1.x = this.containerView.width / 2 - (tab1.width + tab2.width + 50) / 2;
        tab1.y = title.height * 0.7;
        this.containerView.addChild(tab1);
        tab2.x = tab1.x + tab1.width + 50;
        tab2.y = title.height * 0.7;
        this.containerView.addChild(tab2);
        var scroller = new egret.ScrollView();
        scroller.width = this.containerView.width;
        scroller.height = this.containerView.height - title.height - tab1.height - 10;
        scroller.y = this.containerView.height - scroller.height - 20;
        this.containerView.addChild(scroller);
        this.scroller = scroller;
        var scroller2 = new egret.ScrollView();
        scroller2.width = this.containerView.width;
        scroller2.height = this.containerView.height - title.height - tab1.height - 10;
        scroller2.y = this.containerView.height - scroller2.height - 20;
        this.containerView.addChild(scroller2);
        this.gangScroller = scroller2;
        this.gangScroller.visible = false;
        this.contentView = utils.createSprite({
            width: scroller.width
        });
        scroller.setContent(this.contentView);
        var gangView = utils.createSprite({
            width: scroller2.width
        });
        scroller2.setContent(gangView);
        var totalY = 0;
        for (var index = 0; index < data.length; index++) {
            var rankItem = new RankItem(index + 1);
            rankItem.x = 10;
            rankItem.y = totalY;
            totalY += rankItem.height;
            this.contentView.addChild(rankItem);
            var list = data[index].props;
            for (var i = 0; i < list.length; i++) {
                var item = new RewardItem(list[i]);
                item.x = this.contentView.width / 2 - item.width / 2;
                item.y = totalY;
                totalY += item.height;
                this.contentView.addChild(item);
            }
        }
        this.contentView.graphics.beginFill(0x000000, 0);
        this.contentView.graphics.drawRect(0, 0, this.contentView.width, this.contentView.height);
        this.contentView.graphics.endFill();
        var totalY2 = 0;
        for (var index = 0; index < data2.length; index++) {
            var rankItem = new RankItem(index + 1);
            rankItem.x = 10;
            rankItem.y = totalY2;
            totalY2 += rankItem.height;
            gangView.addChild(rankItem);
            var list = data2[index].props;
            for (var i = 0; i < list.length; i++) {
                var item = new RewardItem(list[i]);
                item.x = gangView.width / 2 - item.width / 2;
                item.y = totalY2;
                totalY2 += item.height;
                gangView.addChild(item);
            }
        }
        gangView.graphics.beginFill(0x000000, 0);
        gangView.graphics.drawRect(0, 0, gangView.width, gangView.height);
        gangView.graphics.endFill();
        var btn_close = utils.createBitmapByName('x', { offsetX: 0.5, offsetY: 0.5 });
        btn_close.x = this.containerView.width - 5;
        btn_close.y = 5;
        btn_close.touchEnabled = true;
        btn_close.addEventListener(egret.TouchEvent.TOUCH_TAP, this.remove, this);
        this.containerView.addChild(btn_close);
    };
    // 添加动画
    RewardView.prototype.addAnimation = function () {
        this.containerView.scaleX = 0.1;
        this.containerView.scaleY = 0.1;
        egret.Tween.removeTweens(this.containerView);
        egret.Tween.get(this.containerView).to({ scaleX: 1, scaleY: 1 }, 500, egret.Ease.backOut);
    };
    RewardView.prototype.remove = function () {
        Main.removeRewardView();
    };
    RewardView.prototype.changePersonal = function () {
        if (this.personalTab.isSelected) {
            return;
        }
        this.personalTab.changeSelected(true);
        this.gangTab.changeSelected(false);
        this.scroller.visible = true;
        this.gangScroller.visible = false;
    };
    RewardView.prototype.changeGang = function () {
        if (this.gangTab.isSelected) {
            return;
        }
        this.personalTab.changeSelected(false);
        this.gangTab.changeSelected(true);
        this.scroller.visible = false;
        this.gangScroller.visible = true;
    };
    return RewardView;
}(BaseView));
__reflect(RewardView.prototype, "RewardView");
var TabItem = (function (_super) {
    __extends(TabItem, _super);
    function TabItem(config) {
        var _this = _super.call(this) || this;
        _this.isSelected = false;
        _this.config = {};
        _this.config = config;
        _this.initView();
        _this.touchEnabled = true;
        return _this;
    }
    TabItem.prototype.initView = function () {
        var config = this.config;
        var bg = utils.createBitmapByName(config.default_bg || 'tab2');
        this.addChild(bg);
        this.bg = bg;
        var txt = utils.createTextField({
            width: bg.width,
            height: bg.height,
            text: config.content,
            textColor: config.default_color || 0xF5C388,
            stroke: config.stroke || 2,
            strokeColor: config.stroke_color || 0x7F4611,
            size: config.size || 30
        });
        this.addChild(txt);
        this.text = txt;
    };
    TabItem.prototype.changeSelected = function (selected) {
        if (this.isSelected == selected) {
            return;
        }
        this.isSelected = selected;
        if (selected) {
            this.bg.texture = RES.getRes(this.config.selecte_bg || 'tab3');
            this.text.textColor = this.config.selecte_color || 0x7F4611;
            this.text.strokeColor = this.config.selecte_stroke_color || 0xF5C388;
        }
        else {
            this.bg.texture = RES.getRes(this.config.default_bg || 'tab2');
            this.text.textColor = this.config.default_color || 0xF5C388;
            this.text.strokeColor = this.config.stroke_color || 0x7F4611;
        }
    };
    return TabItem;
}(egret.Sprite));
__reflect(TabItem.prototype, "TabItem");
/**
 * Created by Dean on 2018-8-27.
 */
var BhJiFenCell = (function (_super) {
    __extends(BhJiFenCell, _super);
    function BhJiFenCell() {
        var _this = _super.call(this) || this;
        _this.showPayIndex = -1;
        _this.rank = 1;
        _this.width = BhJiFenCell.CELLWIDTH;
        _this.height = 150;
        _this.bg = utils.createBitmapByName("hi_rank_cell1");
        _this.bg.height = 146;
        _this.bg.width = _this.width - 30;
        _this.bg.y = (_this.height - _this.bg.height) / 2;
        _this.bg.x = 15;
        // this.addChild(this.bg);
        _this.bh_img = utils.createBitmapByName("bhicon");
        // this.bh_img.height = 146;
        // this.bh_img.width = this.width - 30;
        _this.bh_img.y = 15;
        _this.bh_img.x = 100;
        _this.addChild(_this.bh_img);
        _this.bh_name = utils.createTextField();
        _this.bh_name.size = 24;
        _this.bh_name.textColor = 0xFFFFFF;
        _this.bh_name.stroke = 2;
        _this.bh_name.bold = true;
        _this.bh_name.strokeColor = 0x6A410D;
        _this.bh_name.x = 170;
        _this.bh_name.y = 20;
        _this.bh_name.width = 220;
        _this.bh_name.textAlign = "left";
        _this.addChild(_this.bh_name);
        _this.img_bg = utils.createBitmapByName("level5");
        _this.img_bg.width = 60;
        _this.img_bg.height = 60;
        _this.img_bg.x = 100;
        _this.img_bg.y = 65;
        // this.addChild(this.img_bg);
        _this.img = new eui.Image();
        _this.img.width = 50;
        _this.img.height = 50;
        _this.img.x = 105;
        _this.img.y = 70;
        var maskShape = new egret.Shape();
        maskShape.graphics.beginFill(0x000000, 1);
        maskShape.graphics.drawRoundRect(_this.img.x, _this.img.y, 50, 50, 20, 20);
        maskShape.graphics.endFill();
        _this.addChild(maskShape);
        _this.img.mask = maskShape;
        _this.level_name = utils.createBitmapByName("levelname1");
        _this.level_name.x = 105;
        _this.level_name.y = 100;
        _this.level_name.width = 75;
        _this.level_name.height = 22;
        _this.index_img = utils.createBitmapByName("1");
        _this.index_img.x = 15;
        _this.index_img.y = (_this.height - _this.index_img.height) / 2;
        // this.addChild(this.index_img);
        _this.index_text = utils.createTextField();
        // this.index_text.text = "1";
        _this.index_text.size = 35;
        _this.index_text.textColor = 0xFFEA70;
        _this.index_text.stroke = 2;
        _this.index_text.bold = true;
        _this.index_text.strokeColor = 0x6A410D;
        _this.index_text.x = 25;
        _this.index_text.y = 60;
        _this.index_text.width = 70;
        // this.addChild(this.index_text);
        _this.name_text = utils.createTextField();
        _this.name_text.size = 24;
        _this.name_text.textColor = 0x6A410D;
        _this.name_text.bold = true;
        _this.name_text.width = 270;
        _this.name_text.y = 90;
        _this.name_text.x = 170;
        _this.name_text.textAlign = "left";
        _this.addChild(_this.name_text);
        // this.bh_time_bg = utils.createBitmapByName("bh_time1");
        // this.bh_time_bg.x = 380;
        // this.bh_time_bg.y = 5;
        // this.addChild(this.bh_time_bg);
        // this.gr_jifen_time = utils.createTextField();
        // // this.gr_jifen_time.text = "2018.11.14 18:22:22";
        // this.gr_jifen_time.size = 18;
        // this.gr_jifen_time.textColor = 0x6A410D;
        // this.gr_jifen_time.x = 400;
        // this.gr_jifen_time.y = 10;
        // this.addChild(this.gr_jifen_time);
        _this.jf_bg = utils.createBitmapByName("jf_bg_1");
        _this.jf_bg.width = 140;
        _this.jf_bg.height = 75;
        _this.jf_bg.x = 440;
        _this.jf_bg.y = 10;
        _this.addChild(_this.jf_bg);
        _this.gr_jifen_title = utils.createTextField();
        _this.gr_jifen_title.text = "帮会积分";
        _this.gr_jifen_title.size = 24;
        _this.gr_jifen_title.textColor = 0x6A410D;
        _this.gr_jifen_title.bold = true;
        _this.gr_jifen_title.x = 450;
        _this.gr_jifen_title.y = 20;
        _this.gr_jifen_title.width = 120;
        _this.addChild(_this.gr_jifen_title);
        _this.jifen_text = utils.createTextField();
        // this.jifen_text.text = "300";
        _this.jifen_text.size = 28;
        _this.jifen_text.textColor = 0xF6CD57;
        _this.jifen_text.stroke = 2;
        _this.jifen_text.bold = true;
        _this.jifen_text.strokeColor = 0x6A410D;
        _this.jifen_text.x = 450;
        _this.jifen_text.y = 50;
        _this.jifen_text.width = 130;
        // this.jifen_text.textAlign = "left";
        _this.addChild(_this.jifen_text);
        _this.box_img = utils.createBitmapByName("box_1");
        _this.addChild(_this.box_img);
        //弹出奖励明细
        _this.box_img.touchEnabled = true;
        _this.box_img.addEventListener(egret.TouchEvent.TOUCH_TAP, function (evt) {
            BhJiFenCell.jfView.showAwardList(this.rank, this.box_img.x, evt, "bh");
        }, _this);
        return _this;
    }
    BhJiFenCell.prototype.dataChanged = function () {
        var data = this.data;
        this.rank = data.rank;
        if (data.rank > 3) {
            this.index_text.text = data.rank;
            if (this.contains(this.index_img)) {
                this.removeChild(this.index_img);
            }
            this.addChild(this.index_text);
            this.bg.texture = RES.getRes("hi_rank_cell4");
            this.addChild(this.bg);
            // this.bh_time_bg.texture = RES.getRes("bh_time2");
            // this.bh_time_bg.x = 390;
            this.jf_bg.visible = false;
            //判断是否显示宝箱
            if (data.rank <= GameData.gangRank.length) {
                this.box_img.visible = true;
                this.box_img.texture = RES.getRes("box_4");
            }
            else {
                this.box_img.visible = false;
            }
        }
        else {
            if (this.contains(this.index_text)) {
                this.removeChild(this.index_text);
            }
            this.bg.texture = RES.getRes("hi_rank_cell" + data.rank);
            this.addChild(this.bg);
            this.index_img.texture = RES.getRes(data.rank + "");
            this.addChild(this.index_img);
            // this.bh_time_bg.texture = RES.getRes("bh_time1");
            this.jf_bg.visible = true;
            this.jf_bg.texture = RES.getRes("jf_bg_" + data.rank);
            this.box_img.texture = RES.getRes("box_" + data.rank);
        }
        this.img_bg.texture = RES.getRes("level" + data.level_no);
        this.addChild(this.img_bg);
        this.img.source = data.head_url;
        this.addChild(this.img);
        this.box_img.anchorOffsetX = this.box_img.width / 2;
        this.box_img.anchorOffsetY = this.box_img.height / 2;
        this.box_img.y = this.jf_bg.y + this.jf_bg.height - 5 + this.box_img.height / 2;
        this.box_img.x = 520;
        //帮会角标
        this.bz = utils.createBitmapByName("bz");
        this.bz.x = 100;
        this.bz.y = 65;
        this.bz.width = 35;
        this.bz.height = 40;
        this.addChild(this.bz);
        this.level_name.texture = RES.getRes("levelname" + data.level_no);
        this.addChild(this.level_name);
        var name_text_str = "帮主：" + data.nickname;
        name_text_str = utils.getChar(name_text_str, 30);
        this.name_text.text = name_text_str;
        // this.gr_jifen_time.text = data.last_add_time.replace(/-/g,'.');
        this.jifen_text.text = data.total_score;
        var bh_name_str = data.gang_name;
        bh_name_str = utils.getChar(bh_name_str, 24);
        this.bh_name.text = bh_name_str;
        this.setChildIndex(this.bg, 0);
        if (data.rank == 1) {
            this.gr_jifen_title.textColor = 0xFCB42E;
            this.jifen_text.strokeColor = 0x6A410D;
            this.gr_jifen_title.bold = true;
            this.gr_jifen_title.stroke = 1;
        }
        else if (data.rank == 2) {
            this.gr_jifen_title.textColor = 0xECECEC;
            this.jifen_text.strokeColor = 0x6E6E6E;
            this.gr_jifen_title.bold = true;
            this.gr_jifen_title.stroke = 1;
        }
        else if (data.rank == 3) {
            this.gr_jifen_title.textColor = 0xF7C97B;
            this.jifen_text.strokeColor = 0x6A410D;
            this.gr_jifen_title.bold = true;
            this.gr_jifen_title.stroke = 1;
        }
        else {
            this.gr_jifen_title.textColor = 0x6A410D;
            this.jifen_text.strokeColor = 0;
            this.gr_jifen_title.bold = false;
            this.gr_jifen_title.stroke = 0;
        }
    };
    BhJiFenCell.CELLWIDTH = 0;
    BhJiFenCell.jfView = null;
    return BhJiFenCell;
}(eui.ItemRenderer));
__reflect(BhJiFenCell.prototype, "BhJiFenCell");
/**
 * Created by Dean on 2018-8-27.
 */
var JiFenCell = (function (_super) {
    __extends(JiFenCell, _super);
    function JiFenCell() {
        var _this = _super.call(this) || this;
        _this.showPayIndex = -1;
        _this.rank = 1;
        _this.width = JiFenCell.CELLWIDTH;
        _this.height = 150;
        _this.bg = utils.createBitmapByName("hi_rank_cell1");
        _this.bg.height = 146;
        _this.bg.width = _this.width - 30;
        _this.bg.y = (_this.height - _this.bg.height) / 2;
        _this.bg.x = 15;
        // this.addChild(this.bg);
        _this.img_bg = utils.createBitmapByName("level5");
        _this.img_bg.width = 100;
        _this.img_bg.height = 100;
        _this.img_bg.x = 100;
        _this.img_bg.y = (_this.height - _this.img_bg.height) / 2;
        // this.addChild(this.img_bg);
        _this.img = new eui.Image();
        _this.img.width = 75;
        _this.img.height = 75;
        _this.img.x = 112;
        _this.img.y = (_this.height - _this.img.height) / 2;
        var maskShape = new egret.Shape();
        maskShape.graphics.beginFill(0x000000, 1);
        maskShape.graphics.drawRoundRect(_this.img.x, _this.img.y, 75, 75, 40, 40);
        maskShape.graphics.endFill();
        _this.addChild(maskShape);
        _this.img.mask = maskShape;
        _this.level_name = utils.createBitmapByName("levelname1");
        _this.level_name.x = 105;
        _this.level_name.y = 90;
        _this.index_img = utils.createBitmapByName("1");
        _this.index_img.x = 15;
        _this.index_img.y = (_this.height - _this.index_img.height) / 2;
        // this.addChild(this.index_img);
        _this.index_text = utils.createTextField();
        // this.index_text.text = "1";
        _this.index_text.size = 35;
        _this.index_text.textColor = 0xFFEA70;
        _this.index_text.stroke = 2;
        _this.index_text.bold = true;
        _this.index_text.strokeColor = 0x6A410D;
        _this.index_text.x = 25;
        _this.index_text.y = 60;
        _this.index_text.width = 70;
        // this.addChild(this.index_text);
        _this.name_text = utils.createTextField();
        // this.name_text.text = "黄金时间";
        _this.name_text.size = 24;
        _this.name_text.textColor = 0x6A410D;
        _this.name_text.bold = true;
        _this.name_text.width = 230;
        _this.name_text.y = 40;
        _this.name_text.x = 210;
        _this.name_text.textAlign = "left";
        _this.addChild(_this.name_text);
        _this.gr_jifen_time = utils.createTextField();
        // this.gr_jifen_time.text = "2018.11.14 18:22:22";
        _this.gr_jifen_time.size = 20;
        _this.gr_jifen_time.textColor = 0x6A410D;
        _this.gr_jifen_time.x = 210;
        _this.gr_jifen_time.y = 90;
        // gr_jifen_title.width = 100;
        // gr_jifen_title.textAlign = "left";
        // this.addChild(this.gr_jifen_time);
        _this.jf_bg = utils.createBitmapByName("jf_bg_1");
        _this.jf_bg.width = 140;
        _this.jf_bg.height = 75;
        _this.jf_bg.x = 440;
        _this.jf_bg.y = 10;
        _this.addChild(_this.jf_bg);
        _this.gr_jifen_title = utils.createTextField();
        _this.gr_jifen_title.text = "个人积分";
        _this.gr_jifen_title.size = 24;
        _this.gr_jifen_title.textColor = 0x6A410D;
        // this.gr_jifen_title.stroke = 2;
        _this.gr_jifen_title.bold = true;
        // this.gr_jifen_title.strokeColor = 0x6A410D;
        _this.gr_jifen_title.x = 450;
        _this.gr_jifen_title.y = 20;
        _this.gr_jifen_title.width = 120;
        // gr_jifen_title.textAlign = "left";
        _this.addChild(_this.gr_jifen_title);
        _this.jifen_text = utils.createTextField();
        // this.jifen_text.text = "300";
        _this.jifen_text.size = 28;
        // this.jifen_text.textColor = 0xF6CD57;
        // this.jifen_text.stroke = 2;
        // this.jifen_text.bold = true;
        // this.jifen_text.strokeColor = 0x6A410D;
        _this.jifen_text.textColor = 0xF6CD57;
        _this.jifen_text.stroke = 2;
        _this.jifen_text.bold = true;
        _this.jifen_text.strokeColor = 0x6A410D;
        _this.jifen_text.x = 450;
        _this.jifen_text.y = 50;
        _this.jifen_text.width = 130;
        // this.jifen_text.textAlign = "left";
        _this.addChild(_this.jifen_text);
        _this.box_img = utils.createBitmapByName("box_1");
        _this.addChild(_this.box_img);
        //弹出奖励明细
        _this.box_img.touchEnabled = true;
        _this.box_img.addEventListener(egret.TouchEvent.TOUCH_TAP, function (evt) {
            JiFenCell.jfView.showAwardList(this.rank, this.box_img.x, evt, "gr");
        }, _this);
        return _this;
    }
    JiFenCell.prototype.dataChanged = function () {
        var data = this.data;
        var rank = data.rank;
        this.rank = rank;
        if (data.rank > 3) {
            this.index_text.text = data.rank;
            if (this.contains(this.index_img)) {
                this.removeChild(this.index_img);
            }
            this.addChild(this.index_text);
            this.bg.texture = RES.getRes("hi_rank_cell4");
            this.addChild(this.bg);
            this.jf_bg.visible = false;
            //判断是否显示宝箱
            if (data.rank <= GameData.personalRank.length) {
                this.box_img.visible = true;
                this.box_img.texture = RES.getRes("box_4");
            }
            else {
                this.box_img.visible = false;
            }
        }
        else {
            if (this.contains(this.index_text)) {
                this.removeChild(this.index_text);
            }
            this.bg.texture = RES.getRes("hi_rank_cell" + data.rank);
            this.addChild(this.bg);
            this.index_img.texture = RES.getRes(data.rank + "");
            this.addChild(this.index_img);
            this.jf_bg.visible = true;
            this.jf_bg.texture = RES.getRes("jf_bg_" + data.rank);
            this.box_img.visible = true;
            this.box_img.texture = RES.getRes("box_" + data.rank);
        }
        this.img_bg.texture = RES.getRes("level" + data.level_no);
        this.addChild(this.img_bg);
        this.img.source = data.head_url;
        this.addChild(this.img);
        this.level_name.texture = RES.getRes("levelname" + data.level_no);
        this.addChild(this.level_name);
        var name_text_str = data.nickname;
        name_text_str = utils.getChar(name_text_str, 24);
        this.name_text.text = name_text_str;
        if (data.last_add_time) {
            this.gr_jifen_time.text = data.last_add_time.replace(/-/g, '.');
            this.addChild(this.gr_jifen_time);
        }
        this.jifen_text.text = data.total_score;
        this.box_img.anchorOffsetX = this.box_img.width / 2;
        this.box_img.anchorOffsetY = this.box_img.height / 2;
        this.box_img.y = this.jf_bg.y + this.jf_bg.height - 5 + this.box_img.height / 2;
        this.box_img.x = 520;
        if (data.rank == 1) {
            this.gr_jifen_title.textColor = 0xFCB42E;
            //    this.jifen_text.strokeColor = 0x6A410D;
            this.gr_jifen_title.bold = true;
            this.gr_jifen_title.stroke = 1;
        }
        else if (data.rank == 2) {
            this.gr_jifen_title.textColor = 0xECECEC;
            //    this.jifen_text.strokeColor = 0x6E6E6E;
            this.gr_jifen_title.bold = true;
            this.gr_jifen_title.stroke = 1;
        }
        else if (data.rank == 3) {
            this.gr_jifen_title.textColor = 0xF7C97B;
            //    this.jifen_text.strokeColor = 0x6A410D;
            this.gr_jifen_title.bold = true;
            this.gr_jifen_title.stroke = 1;
        }
        else {
            this.gr_jifen_title.textColor = 0x6A410D;
            //    this.jifen_text.strokeColor = 0;
            this.gr_jifen_title.bold = false;
            this.gr_jifen_title.stroke = 0;
        }
        this.setChildIndex(this.bg, 0);
    };
    JiFenCell.CELLWIDTH = 0;
    JiFenCell.jfView = null;
    return JiFenCell;
}(eui.ItemRenderer));
__reflect(JiFenCell.prototype, "JiFenCell");
var JiFenRankView = (function (_super) {
    __extends(JiFenRankView, _super);
    function JiFenRankView() {
        var _this = _super.call(this) || this;
        _this.now_tab = 0;
        _this.end_time = 0;
        _this.type = 1; //1-本期奖励 2-下期奖励
        _this.hasTimerEvent = false;
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.initView, _this);
        return _this;
    }
    JiFenRankView.prototype.queryGrRank = function () {
        this.now_tab = 1;
        var _that = this;
        var params = {
            'count': 50
        };
        CurlUtil.curl(config.api_url + '/bxg/rank/personal/now', params).then(function (data) {
            if (_that.now_tab == 2) {
                return;
            }
            if (data.status == "success") {
                _that.createGrJiFenView(data.data);
            }
            else {
                // Toast.makeText({ text: '调用接口失败！{code:'+data.code+'}' }).show();
                _that.showEmpty();
            }
        }).catch(function () {
            // Toast.makeText({ text: '调用接口失败！' }).show();
            _that.showEmpty();
        });
    };
    JiFenRankView.prototype.queryBhRank = function () {
        this.now_tab = 2;
        var _that = this;
        var params = {
            'count': 50
        };
        CurlUtil.curl(config.api_url + '/bxg/rank/gang/now', params).then(function (data) {
            if (_that.now_tab == 1) {
                return;
            }
            if (data.status == "success") {
                _that.createBhJiFenView(data.data);
            }
            else {
                // Toast.makeText({ text: '调用接口失败！{code:'+data.code+'}' }).show();
                _that.showEmpty();
            }
        }).catch(function () {
            // Toast.makeText({ text: '调用接口失败！' }).show();
            _that.showEmpty();
        });
    };
    JiFenRankView.prototype.showEmpty = function () {
        this.tableView.dataSource = [];
        if (this.contentview.contains(this.my_rank)) {
            this.contentview.removeChild(this.my_rank);
        }
        this.emptyLabel_text.visible = true;
        this.emptyLabel_img.visible = true;
    };
    JiFenRankView.prototype.initView = function () {
        //背景
        if (!this.contains(this.bgMaskShap)) {
            var bgMaskShap = new egret.Shape();
            bgMaskShap.graphics.beginFill(0x000000, 0.6);
            bgMaskShap.graphics.drawRect(0, 0, this.width, this.height);
            bgMaskShap.graphics.endFill();
            bgMaskShap.touchEnabled = true;
            this.bgMaskShap = bgMaskShap;
            this.addChild(bgMaskShap);
        }
        if (!this.contains(this.contentview)) {
            this.contentview = new egret.DisplayObjectContainer;
            this.addChild(this.contentview);
            this.contentview.width = this.width;
            this.contentview.height = this.height;
            this.contentview.x = (this.contentview.width) / 2;
            this.contentview.y = (this.contentview.height) / 2;
            this.contentview.anchorOffsetX = this.contentview.width / 2;
            this.contentview.anchorOffsetY = this.contentview.height / 2;
        }
        //背景图
        if (!this.contentview.contains(this.contentviewbg)) {
            var contentviewbg = utils.createBitmapByName('friend');
            contentviewbg.scale9Grid = new egret.Rectangle(250, 160, 100, 50);
            contentviewbg.height = this.height * 0.9;
            contentviewbg.width = this.width * 0.95;
            contentviewbg.anchorOffsetX = contentviewbg.width / 2;
            contentviewbg.anchorOffsetY = contentviewbg.height / 2;
            contentviewbg.x = (this.width) / 2;
            contentviewbg.y = (this.height) / 2;
            this.contentviewbg = contentviewbg;
            this.contentview.addChild(contentviewbg);
        }
        //tabbar背景
        if (!this.contentview.contains(this.bg_jf)) {
            var bg_jf = utils.createBitmapByName("bg_jf");
            bg_jf.width = contentviewbg.width * 0.85;
            bg_jf.height = contentviewbg.height * 0.65;
            bg_jf.y = 300;
            bg_jf.x = (this.width - bg_jf.width) / 2;
            this.contentview.addChild(bg_jf);
            this.bg_jf = bg_jf;
        }
        //积分榜
        if (!this.contentview.contains(this.title)) {
            var title = utils.createTextField();
            title.text = "积分榜";
            title.size = 60;
            title.textColor = 0xFFEA70;
            title.stroke = 5;
            title.bold = true;
            title.strokeColor = 0x6A410D;
            title.x = (this.width - title.width) / 2;
            title.y = 100;
            this.title = title;
            this.contentview.addChild(title);
        }
        //关闭按钮
        if (!this.contentview.contains(this.close_btn)) {
            var close_btn = utils.createBitmapByName("x", { offsetX: 0.5, offsetY: 0.5 });
            close_btn.x = 682;
            close_btn.y = 136;
            close_btn.touchEnabled = true;
            close_btn.touchAnimation = true;
            this.close_btn = close_btn;
            this.contentview.addChild(close_btn);
            close_btn.addEventListener(egret.TouchEvent.TOUCH_TAP, function () {
                Main.removeJFView();
            }, this);
        }
        //个人排行榜
        if (!this.contentview.contains(this.gr_Container)) {
            var gr_Container = new egret.DisplayObjectContainer;
            this.contentview.addChild(gr_Container);
            this.gr_Container = gr_Container;
            var gr_btn = utils.createBitmapByName("tab1");
            gr_btn.x = 70;
            gr_btn.y = 210;
            gr_btn.touchEnabled = true;
            gr_Container.addChild(gr_btn);
            this.gr_btn = gr_btn;
            var gr_text = utils.createTextField();
            gr_text.x = gr_btn.x;
            gr_text.y = 210;
            gr_text.width = gr_btn.width;
            gr_text.height = (gr_btn.width * 66) / 190;
            gr_text.textAlign = "center";
            gr_text.verticalAlign = egret.VerticalAlign.MIDDLE;
            gr_text.text = "个人积分榜";
            gr_text.size = 30;
            gr_text.textColor = 0xFFEA70;
            gr_text.stroke = 2;
            gr_text.bold = true;
            gr_text.strokeColor = 0x6A410D;
            this.gr_text = gr_text;
            gr_Container.addChild(gr_text);
            gr_Container.touchEnabled = true;
            gr_Container.addEventListener(egret.TouchEvent.TOUCH_TAP, function () {
                this.gr_btn.texture = RES.getRes("tab1");
                this.bh_btn.texture = RES.getRes("tab2");
                this.gr_text.textColor = 0xFFEA70;
                this.bh_text.textColor = 0xEBC275;
                if (this.now_tab == 1) {
                    return;
                }
                this.queryGrRank();
            }, this);
        }
        //帮会排行榜
        if (!this.contentview.contains(this.bh_Container)) {
            var bh_Container = new egret.DisplayObjectContainer;
            this.contentview.addChild(bh_Container);
            this.bh_Container = bh_Container;
            var bh_btn = utils.createBitmapByName("tab2");
            bh_btn.x = gr_btn.x + gr_btn.width + 30;
            bh_btn.y = 210;
            bh_btn.touchEnabled = true;
            bh_Container.addChild(bh_btn);
            this.bh_btn = bh_btn;
            var bh_text = utils.createTextField();
            bh_text.x = bh_btn.x;
            bh_text.width = bh_btn.width;
            bh_text.y = 210;
            bh_text.height = (bh_btn.width * 66) / 190;
            bh_text.textAlign = "center";
            bh_text.verticalAlign = egret.VerticalAlign.MIDDLE;
            bh_text.text = "帮会积分榜";
            bh_text.size = 30;
            bh_text.textColor = 0xEBC275;
            bh_text.stroke = 2;
            bh_text.bold = true;
            bh_text.strokeColor = 0x6A410D;
            bh_Container.addChild(bh_text);
            this.bh_text = bh_text;
            bh_Container.touchEnabled = true;
            bh_Container.addEventListener(egret.TouchEvent.TOUCH_TAP, function () {
                this.bh_btn.texture = RES.getRes("tab1");
                this.gr_btn.texture = RES.getRes("tab2");
                this.bh_text.textColor = 0xFFEA70;
                this.gr_text.textColor = 0xEBC275;
                if (this.now_tab == 2) {
                    return;
                }
                this.queryBhRank();
            }, this);
        }
        //上期奖励分配按钮
        if (!this.contentview.contains(this.sq_btn)) {
            var sq_btn = utils.createBitmapByName("sqfp");
            sq_btn.x = bh_btn.x + bh_btn.width + 30;
            sq_btn.y = 225;
            sq_btn.touchEnabled = true;
            this.sq_btn = sq_btn;
            this.contentview.addChild(sq_btn);
            sq_btn.touchEnabled = true;
            sq_btn.addEventListener(egret.TouchEvent.TOUCH_TAP, function () {
                Main.removeJFView();
                Main.showLastJFView();
            }, this);
        }
        //列表
        if (!this.contentview.contains(this.tableView)) {
            var tableView = new TableView.TableView();
            tableView.height = this.bg_jf.height - 100;
            tableView.scrollPolicyH = "false";
            // tableView.scrollPolicyV = "false";  
            tableView.width = this.bg_jf.width;
            tableView.anchorOffsetX = tableView.width / 2;
            tableView.x = (this.width) / 2;
            tableView.y = this.bg_jf.y + 6;
            this.tableView = tableView;
            this.contentview.addChild(this.tableView);
        }
        if (!this.contentview.contains(this.emptyLabel_img)) {
            this.emptyLabel_img = utils.createBitmapByName("dj_icon");
            this.emptyLabel_img.x = (this.width - this.emptyLabel_img.width) / 2;
            this.emptyLabel_img.y = (this.height - this.emptyLabel_img.height) / 2;
            this.contentview.addChild(this.emptyLabel_img);
            this.emptyLabel_img.visible = false;
        }
        if (!this.contentview.contains(this.emptyLabel_text)) {
            this.emptyLabel_text = new BaseTextField();
            this.emptyLabel_text.text = "暂无数据!";
            this.emptyLabel_text.width = this.width;
            this.emptyLabel_text.y = this.contentview.y + this.emptyLabel_img.height / 2 + 10;
            this.emptyLabel_text.textColor = 0xc19b61;
            this.emptyLabel_text.visible = false;
            this.emptyLabel_text.textAlign = "center";
            this.contentview.addChild(this.emptyLabel_text);
        }
        if (this.now_tab == 2) {
            this.queryBhRank();
        }
        else {
            this.queryGrRank();
        }
        this.addAnimation();
        if (this.type == 1 && this.end_time > 0) {
            //显示倒计时
            this.createEndView();
        }
    };
    // private getFnt(){
    //     RES.getResByUrl( "resource/assets/sz.fnt", this.createEndView, this,
    //         RES.ResourceItem.TYPE_FONT );
    // }
    //显示倒计时
    JiFenRankView.prototype.createEndView = function () {
        var _this = this;
        this.end_view = new egret.DisplayObjectContainer;
        this._bitmapText = new egret.BitmapText();
        this._bitmapText.font = RES.getRes("sz_fnt");
        this._bitmapText.text = utils.timerSecondFormat(this.end_time);
        this._bitmapText.letterSpacing = 5;
        this.contentview.addChild(this.end_view);
        var text = utils.createTextField({
            height: this._bitmapText.height
        });
        // text.width = view_1.width;
        // text.height = this._bitmapText.height;
        text.text = "距离结束 ";
        text.size = 27;
        text.textColor = 0x7E3E0F;
        // text.verticalAlign = egret.VerticalAlign.MIDDLE;
        text.textAlign = 'center';
        text.bold = true;
        this.end_view.addChild(text);
        this._bitmapText.x = text.width;
        this.end_view.addChild(this._bitmapText);
        this.end_view.x = (this.contentview.width - this.end_view.width) / 2;
        this.end_view.y = this.bg_jf.y + this.bg_jf.height + 20;
        if (!this.countdown) {
            this.countdown = new egret.Timer(1000);
            this.countdown.addEventListener(egret.TimerEvent.TIMER, function () {
                _this.end_time--;
                if (_this.end_time == 0) {
                    _this.countdown.stop();
                    Main.removeJFView();
                }
                _this._bitmapText.text = utils.timerSecondFormat(_this.end_time);
            }, this);
        }
        this.countdown.start();
    };
    // 添加动画
    JiFenRankView.prototype.addAnimation = function () {
        this.contentview.scaleX = this.contentview.scaleY = 0;
        egret.Tween.removeTweens(this.contentview);
        egret.Tween.get(this.contentview).to({ scaleX: 1, scaleY: 1 }, 500, egret.Ease.backOut);
    };
    /**
     * 创建个人排行榜
     */
    JiFenRankView.prototype.createGrJiFenView = function (data) {
        this.emptyLabel_text.visible = false;
        this.emptyLabel_img.visible = false;
        var dataSource = data.list;
        this.tableView.dataSource = dataSource;
        this.tableView.itemRenderer = JiFenCell;
        JiFenCell.CELLWIDTH = this.tableView.width;
        JiFenCell.jfView = this;
        if (dataSource.length <= 0) {
            this.emptyLabel_text.visible = true;
            this.emptyLabel_img.visible = true;
        }
        if (this.contentview.contains(this.my_rank)) {
            this.contentview.removeChild(this.my_rank);
        }
        if (!data.last_add_time) {
            this.tableView.height = this.bg_jf.height - 25;
            return;
        }
        else {
            this.tableView.height = this.bg_jf.height - 100;
        }
        this.my_rank = new egret.DisplayObjectContainer();
        //我的排名
        var bg = utils.createBitmapByName("paiming_mine");
        this.my_rank.width = this.bg_jf.width + 10;
        this.my_rank.height = 160;
        this.my_rank.x = (this.width - this.my_rank.width) / 2;
        this.my_rank.y = this.bg_jf.y + this.bg_jf.height - 150;
        bg.height = this.my_rank.height;
        bg.width = this.my_rank.width;
        this.my_rank.addChild(bg);
        this.contentview.addChild(this.my_rank);
        var img_bg = utils.createBitmapByName("level" + data.level_no);
        img_bg.width = 100;
        img_bg.height = 100;
        img_bg.x = 30;
        img_bg.y = 40;
        this.my_rank.addChild(img_bg);
        var img = new eui.Image();
        img.width = 75;
        img.height = 75;
        img.x = 42;
        img.y = 50;
        var maskShape = new egret.Shape();
        maskShape.graphics.beginFill(0x000000, 1);
        maskShape.graphics.drawRoundRect(img.x, img.y, 75, 75, 40, 40);
        maskShape.graphics.endFill();
        this.my_rank.addChild(maskShape);
        img.mask = maskShape;
        img.source = data.head_url;
        this.my_rank.addChild(img);
        var level_name = utils.createBitmapByName("levelname" + data.level_no);
        level_name.x = 35;
        level_name.y = 110;
        this.my_rank.addChild(level_name);
        var name_text_str = data.nickname;
        name_text_str = utils.getChar(name_text_str, 24);
        var name_text = utils.createTextField();
        name_text.size = 26;
        name_text.textColor = 0xFFFFFF;
        name_text.stroke = 2;
        // name_text.bold = true;
        name_text.strokeColor = 0x6A410D;
        name_text.x = 150;
        name_text.y = 50;
        name_text.width = 270;
        name_text.text = name_text_str;
        name_text.textAlign = "left";
        this.my_rank.addChild(name_text);
        var gr_jifen_time = utils.createTextField();
        gr_jifen_time.text = data.last_add_time.replace(/-/g, '.');
        gr_jifen_time.size = 20;
        gr_jifen_time.textColor = 0x6A410D;
        gr_jifen_time.x = 150;
        gr_jifen_time.y = 100;
        // gr_jifen_title.width = 100;
        // gr_jifen_title.textAlign = "left";
        this.my_rank.addChild(gr_jifen_time);
        var wsb_str = "未上榜";
        for (var i = 0; i < dataSource.length; i++) {
            if (data.tvmid == dataSource[i].tvmid) {
                wsb_str = "第" + dataSource[i].rank + "名";
            }
        }
        var wsb_text = utils.createTextField();
        wsb_text.size = 35;
        wsb_text.textColor = 0xFFFFFF;
        wsb_text.stroke = 2;
        wsb_text.bold = true;
        wsb_text.strokeColor = 0x6A410D;
        wsb_text.x = 390;
        wsb_text.y = 30;
        wsb_text.width = 200;
        wsb_text.text = wsb_str;
        wsb_text.italic = true;
        wsb_text.textAlign = "right";
        this.my_rank.addChild(wsb_text);
        var jbr_text = utils.createTextField();
        jbr_text.text = "已击败" + data.percent + "%玩家";
        jbr_text.size = 20;
        jbr_text.textColor = 0x6A410D;
        jbr_text.bold = true;
        jbr_text.width = 200;
        jbr_text.y = 80;
        jbr_text.x = 400;
        this.my_rank.addChild(jbr_text);
        var shape = new egret.Shape;
        shape.graphics.beginFill(0x000000, 0.2);
        shape.graphics.drawRoundRect(400, 110, 200, 40, 40, 40);
        shape.graphics.endFill();
        this.my_rank.addChild(shape);
        var grjf_text = utils.createTextField();
        grjf_text.text = "个人积分";
        grjf_text.size = 22;
        grjf_text.textColor = 0x32616B;
        grjf_text.bold = true;
        // grjf_text.width = 200;
        grjf_text.y = 120;
        grjf_text.x = 410;
        this.my_rank.addChild(grjf_text);
        var jifen_text = utils.createTextField();
        jifen_text.text = data.total_score + "";
        jifen_text.size = 26;
        jifen_text.textColor = 0xF6CD57;
        jifen_text.stroke = 2;
        jifen_text.bold = true;
        jifen_text.strokeColor = 0x6A410D;
        jifen_text.width = 100;
        jifen_text.x = 500;
        jifen_text.y = 117;
        this.my_rank.addChild(jifen_text);
    };
    /**
     * 创建帮会排行榜
     */
    JiFenRankView.prototype.createBhJiFenView = function (data) {
        this.emptyLabel_text.visible = false;
        this.emptyLabel_img.visible = false;
        var dataSource = data.list;
        this.tableView.dataSource = dataSource;
        this.tableView.itemRenderer = BhJiFenCell;
        BhJiFenCell.CELLWIDTH = this.tableView.width;
        BhJiFenCell.jfView = this;
        if (dataSource.length <= 0) {
            this.emptyLabel_text.visible = true;
            this.emptyLabel_img.visible = true;
        }
        //帮会排名
        if (this.contentview.contains(this.my_rank)) {
            this.contentview.removeChild(this.my_rank);
        }
        if (!data.last_add_time) {
            this.tableView.height = this.bg_jf.height - 15;
            return;
        }
        else {
            this.tableView.height = this.bg_jf.height - 100;
        }
        this.my_rank = new egret.DisplayObjectContainer();
        var bg = utils.createBitmapByName("banghui_mine");
        this.my_rank.width = this.bg_jf.width + 10;
        this.my_rank.height = 160;
        this.my_rank.x = (this.width - this.my_rank.width) / 2;
        this.my_rank.y = this.bg_jf.y + this.bg_jf.height - 150;
        bg.height = this.my_rank.height;
        bg.width = this.my_rank.width;
        this.my_rank.addChild(bg);
        this.contentview.addChild(this.my_rank);
        var bh_img = utils.createBitmapByName("bhicon");
        // this.bh_img.height = 146;
        // this.bh_img.width = this.width - 30;
        bh_img.y = 45;
        bh_img.x = 40;
        this.my_rank.addChild(bh_img);
        var bh_name_str = data.gang_name;
        bh_name_str = utils.getChar(bh_name_str, 24);
        var bh_name = utils.createTextField();
        bh_name.size = 24;
        bh_name.textColor = 0xFFFFFF;
        bh_name.stroke = 2;
        bh_name.bold = true;
        bh_name.strokeColor = 0x6A410D;
        bh_name.x = 120;
        bh_name.y = 50;
        bh_name.width = 220;
        bh_name.text = bh_name_str;
        bh_name.textAlign = "left";
        this.my_rank.addChild(bh_name);
        var img_bg = utils.createBitmapByName("level" + data.level_no);
        img_bg.width = 60;
        img_bg.height = 60;
        img_bg.x = 40;
        img_bg.y = 90;
        this.my_rank.addChild(img_bg);
        var img = new eui.Image();
        img.width = 50;
        img.height = 50;
        img.x = 45;
        img.y = 95;
        var maskShape = new egret.Shape();
        maskShape.graphics.beginFill(0x000000, 1);
        maskShape.graphics.drawRoundRect(img.x, img.y, 50, 50, 20, 20);
        maskShape.graphics.endFill();
        this.my_rank.addChild(maskShape);
        img.mask = maskShape;
        img.source = data.head_url;
        this.my_rank.addChild(img);
        var level_name = utils.createBitmapByName("levelname" + data.level_no);
        level_name.x = 40;
        level_name.y = 125;
        level_name.width = 75;
        level_name.height = 22;
        this.my_rank.addChild(level_name);
        var name_text_str = "帮主：" + data.nickname;
        name_text_str = utils.getChar(name_text_str, 30);
        var name_text = utils.createTextField();
        name_text.size = 24;
        name_text.textColor = 0x6A410D;
        name_text.bold = true;
        name_text.x = 120;
        name_text.y = 115;
        name_text.width = 270;
        name_text.text = name_text_str;
        name_text.textAlign = "left";
        this.my_rank.addChild(name_text);
        var wsb_str = "所在帮会未上榜";
        for (var i = 0; i < dataSource.length; i++) {
            if (data.gang_uuid == dataSource[i].gang_uuid) {
                wsb_str = "第" + dataSource[i].rank + "名";
            }
        }
        var wsb_text = utils.createTextField();
        wsb_text.size = 35;
        wsb_text.textColor = 0xFFFFFF;
        wsb_text.stroke = 2;
        wsb_text.bold = true;
        wsb_text.strokeColor = 0x6A410D;
        wsb_text.x = 340;
        wsb_text.y = 30;
        wsb_text.width = 250;
        wsb_text.text = wsb_str;
        wsb_text.italic = true;
        wsb_text.textAlign = "right";
        this.my_rank.addChild(wsb_text);
        var shape = new egret.Shape;
        shape.graphics.beginFill(0x000000, 0.2);
        shape.graphics.drawRoundRect(400, 85, 200, 30, 40, 40);
        shape.graphics.endFill();
        this.my_rank.addChild(shape);
        var grjf_text = utils.createTextField();
        grjf_text.text = "帮会积分";
        grjf_text.size = 20;
        grjf_text.textColor = 0x32616B;
        grjf_text.bold = true;
        // grjf_text.width = 200;
        grjf_text.y = 92;
        grjf_text.x = 410;
        this.my_rank.addChild(grjf_text);
        var jifen_text = utils.createTextField();
        jifen_text.text = data.total_score + "";
        jifen_text.size = 24;
        jifen_text.textColor = 0xF6CD57;
        jifen_text.stroke = 2;
        jifen_text.bold = true;
        jifen_text.strokeColor = 0x6A410D;
        jifen_text.width = 120;
        jifen_text.x = 490;
        jifen_text.y = 90;
        // jifen_text.textAlign = "left";
        this.my_rank.addChild(jifen_text);
        var gr_jifen_time = utils.createTextField();
        gr_jifen_time.text = data.last_add_time.replace(/-/g, '.');
        gr_jifen_time.size = 18;
        gr_jifen_time.textColor = 0x6A410D;
        gr_jifen_time.x = 410;
        gr_jifen_time.y = 130;
        // gr_jifen_title.width = 100;
        // gr_jifen_title.textAlign = "left";
        this.my_rank.addChild(gr_jifen_time);
    };
    JiFenRankView.prototype.showAwardList = function (index, x, evt, type) {
        if (this.contentview.contains(this.bgMaskAward)) {
            this.contentview.removeChild(this.bgMaskAward);
        }
        this.bgMaskAward = new egret.Shape();
        this.bgMaskAward.graphics.beginFill(0x000000, 0);
        this.bgMaskAward.graphics.drawRect(0, 0, this.width, this.height);
        this.bgMaskAward.graphics.endFill();
        this.bgMaskAward.touchEnabled = true;
        this.contentview.addChild(this.bgMaskAward);
        this.bgMaskAward.addEventListener(egret.TouchEvent.TOUCH_TAP, function () {
            this.bgMaskAward.visible = false;
            this.award_list_view.visible = false;
        }, this);
        if (this.contentview.contains(this.award_list_view)) {
            this.contentview.removeChild(this.award_list_view);
        }
        this.award_list_view = new egret.DisplayObjectContainer;
        var bg = utils.createBitmapByName("award_bg_png");
        bg.width = this.bg_jf.width;
        this.award_list_view.addChild(bg);
        this.contentview.addChild(this.award_list_view);
        // this.award_list_view.y = y + this.tableView.y;
        this.award_list_view.y = evt.stageY;
        this.award_list_view.x = x - 440;
        this.award_list_view.height = bg.height;
        var data = [];
        if (type == "gr") {
            data = GameData.personalRank[index - 1]['props'];
        }
        else {
            data = GameData.gangRank[index - 1]['props'];
        }
        bg.height = 130 * (Math.floor(data.length / 7) + 1) + 20;
        var width = (bg.width) / 6;
        var height = 130;
        var _loop_1 = function (i) {
            view = new egret.DisplayObjectContainer;
            view.width = width;
            view.height = height;
            view.anchorOffsetX = view.width / 2;
            view.anchorOffsetY = view.height / 2;
            if (i % 6 == 0) {
                view.x = width * 5 + (width / 2);
                view.y = 130 * (Math.floor(i / 6) - 1) + view.height / 2;
            }
            else {
                view.x = width * (i % 6 - 1) + (width / 2);
                view.y = 130 * (Math.floor(i / 6)) + view.height / 2;
            }
            img = new eui.Image();
            var item = data[i - 1];
            img.width = width * 0.75;
            img.height = width * 0.75;
            img.anchorOffsetX = img.width / 2;
            img.anchorOffsetY = img.height / 2;
            img.y = view.height / 2;
            img.x = view.width / 2;
            img.source = item.prop_img;
            view.addChild(img);
            text = utils.createTextField();
            text.size = 16;
            text.textColor = 0x6A410D;
            text.bold = true;
            // text.x = (view.width - text.width)/2;
            text.y = img.y + img.height / 2 + 5;
            text.width = view.width;
            if (item.count > 1) {
                text.text = item.prop_name + " x" + item.count;
            }
            else {
                text.text = item.prop_name;
            }
            view.addChild(text);
            this_1.award_list_view.addChild(view);
            view.addEventListener(egret.TouchEvent.TOUCH_TAP, function () {
                var data_tool = {};
                if (item.type == 1) {
                    data_tool = {
                        "img": item.prop_img,
                        "name": item.prop_name,
                        "desc": item.prop_desc,
                        "type": item.type
                    };
                }
                else {
                    data_tool = {
                        "img": item.prop_img,
                        "name": item.prop_name,
                        "desc": item.prop_desc,
                        "type": item.type,
                        "parent_img": item.parent_img,
                        "parent_name": item.parent_name,
                        "parent_desc": item.parent_desc,
                    };
                }
                Main.showTooInfoView(data_tool);
            }, view);
        };
        var this_1 = this, view, img, text;
        for (var i = 1; i <= data.length; i++) {
            _loop_1(i);
        }
    };
    return JiFenRankView;
}(BaseView));
__reflect(JiFenRankView.prototype, "JiFenRankView");
var LastJiFenRankView = (function (_super) {
    __extends(LastJiFenRankView, _super);
    function LastJiFenRankView() {
        var _this = _super.call(this) || this;
        _this.now_tab = 0;
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.initView, _this);
        return _this;
    }
    LastJiFenRankView.prototype.queryGrRank = function () {
        this.now_tab = 1;
        var _that = this;
        CurlUtil.curl(config.api_url + '/bxg/rank/personal/last', {}).then(function (data) {
            if (_that.now_tab == 2) {
                return;
            }
            if (data.status == "success") {
                _that.createGrJiFenView(data.data);
                // 更新时间显示
                _that.updateDate(data.data['next_time'], data.data['date']);
            }
            else {
                // Toast.makeText({ text: '调用接口失败！{code:'+data.code+'}' }).show();
                _that.showEmpty();
            }
        }).catch(function () {
            // Toast.makeText({ text: '调用接口失败！' }).show();
            _that.showEmpty();
        });
    };
    LastJiFenRankView.prototype.queryBhRank = function () {
        this.now_tab = 2;
        var _that = this;
        CurlUtil.curl(config.api_url + '/bxg/rank/gang/last', {}).then(function (data) {
            if (_that.now_tab == 1) {
                return;
            }
            if (data.status == "success") {
                _that.createBhJiFenView(data.data);
                // 更新时间显示
                _that.updateDate(data.data['next_time'], data.data['date']);
            }
            else {
                // Toast.makeText({ text: '调用接口失败！{code:'+data.code+'}' }).show();
                _that.showEmpty();
            }
        }).catch(function () {
            // Toast.makeText({ text: '调用接口失败！' }).show();
            _that.showEmpty();
        });
    };
    LastJiFenRankView.prototype.showEmpty = function () {
        this.tableView.dataSource = [];
        if (this.contentview.contains(this.my_rank)) {
            this.contentview.removeChild(this.my_rank);
        }
        this.emptyLabel_text.visible = true;
        this.emptyLabel_img.visible = true;
    };
    LastJiFenRankView.prototype.initView = function () {
        this.props_arr = {
            "gr": [],
            "bh": []
        };
        //背景
        if (!this.contains(this.bgMaskShap)) {
            var bgMaskShap = new egret.Shape();
            bgMaskShap.graphics.beginFill(0x000000, 0.6);
            bgMaskShap.graphics.drawRect(0, 0, this.width, this.height);
            bgMaskShap.graphics.endFill();
            bgMaskShap.touchEnabled = true;
            this.bgMaskShap = bgMaskShap;
            this.addChild(bgMaskShap);
        }
        if (!this.contains(this.contentview)) {
            this.contentview = new egret.DisplayObjectContainer;
            this.addChild(this.contentview);
            this.contentview.width = this.width;
            this.contentview.height = this.height;
            this.contentview.x = (this.contentview.width) / 2;
            this.contentview.y = (this.contentview.height) / 2;
            this.contentview.anchorOffsetX = this.contentview.width / 2;
            this.contentview.anchorOffsetY = this.contentview.height / 2;
        }
        //背景图
        if (!this.contentview.contains(this.contentviewbg)) {
            var contentviewbg = utils.createBitmapByName('friend');
            contentviewbg.scale9Grid = new egret.Rectangle(250, 160, 100, 50);
            contentviewbg.height = this.height * 0.9;
            contentviewbg.width = this.width * 0.95;
            contentviewbg.anchorOffsetX = contentviewbg.width / 2;
            contentviewbg.anchorOffsetY = contentviewbg.height / 2;
            contentviewbg.x = (this.width) / 2;
            contentviewbg.y = (this.height) / 2;
            this.contentviewbg = contentviewbg;
            this.contentview.addChild(contentviewbg);
        }
        //tabbar背景
        if (!this.contentview.contains(this.bg_jf)) {
            var bg_jf = utils.createBitmapByName("bg_jf");
            bg_jf.width = contentviewbg.width * 0.85;
            bg_jf.height = this.height * 0.58;
            bg_jf.y = 300;
            bg_jf.x = (this.width - bg_jf.width) / 2;
            this.contentview.addChild(bg_jf);
            this.bg_jf = bg_jf;
        }
        //积分榜
        if (!this.contentview.contains(this.title)) {
            var titleLabel = new BaseTextField();
            titleLabel.text = "上期奖励分配";
            titleLabel.width = this.contentview.width;
            titleLabel.x = (this.width - titleLabel.width) / 2;
            titleLabel.y = 90;
            titleLabel.textAlign = egret.HorizontalAlign.CENTER;
            titleLabel.stroke = 4;
            titleLabel.strokeColor = 0xBA7114;
            titleLabel.textColor = 0xF2E019;
            titleLabel.bold = true;
            titleLabel.size = 38;
            this.title = titleLabel;
            this.contentview.addChild(this.title);
            var todayLabel = new BaseTextField();
            todayLabel.textColor = 0xFFF894;
            todayLabel.text = "";
            todayLabel.width = 188;
            todayLabel.height = 35;
            todayLabel.size = 26;
            todayLabel.textAlign = egret.HorizontalAlign.CENTER;
            todayLabel.verticalAlign = egret.VerticalAlign.MIDDLE;
            todayLabel.x = (this.contentview.width - todayLabel.width) / 2.0;
            todayLabel.y = utils.getMaxY(this.title) + 10;
            this.todayLabel = todayLabel;
            var todayShape = new egret.Shape();
            todayShape.x = this.todayLabel.x;
            todayShape.y = this.todayLabel.y;
            todayShape.width = this.todayLabel.width;
            todayShape.height = this.todayLabel.height;
            todayShape.graphics.beginFill(0x7B490D);
            todayShape.graphics.drawRoundRect(0, 0, todayShape.width, todayShape.height, 20);
            todayShape.graphics.endFill();
            this.todayShape = todayShape;
            this.contentview.addChild(this.todayShape);
            this.contentview.addChild(this.todayLabel);
        }
        //关闭按钮
        if (!this.contentview.contains(this.close_btn)) {
            var close_btn = utils.createBitmapByName("x", { offsetX: 0.5, offsetY: 0.5 });
            close_btn.x = 682;
            close_btn.y = 136;
            close_btn.touchEnabled = true;
            close_btn.touchAnimation = true;
            this.close_btn = close_btn;
            this.contentview.addChild(close_btn);
            close_btn.addEventListener(egret.TouchEvent.TOUCH_TAP, function () {
                Main.removeLastJFView();
            }, this);
        }
        //个人排行榜
        if (!this.contentview.contains(this.gr_Container)) {
            var gr_Container = new egret.DisplayObjectContainer;
            this.contentview.addChild(gr_Container);
            this.gr_Container = gr_Container;
            var gr_btn = utils.createBitmapByName("tab1");
            gr_btn.x = 70;
            gr_btn.y = 210;
            gr_btn.touchEnabled = true;
            gr_Container.addChild(gr_btn);
            this.gr_btn = gr_btn;
            var gr_text = utils.createTextField();
            gr_text.x = gr_btn.x;
            gr_text.y = 210;
            gr_text.width = gr_btn.width;
            gr_text.height = (gr_btn.width * 66) / 190;
            gr_text.textAlign = "center";
            gr_text.verticalAlign = egret.VerticalAlign.MIDDLE;
            gr_text.text = "个人积分榜";
            gr_text.size = 30;
            gr_text.textColor = 0xFFEA70;
            gr_text.stroke = 2;
            gr_text.bold = true;
            gr_text.strokeColor = 0x6A410D;
            this.gr_text = gr_text;
            gr_Container.addChild(gr_text);
            gr_Container.touchEnabled = true;
            gr_Container.addEventListener(egret.TouchEvent.TOUCH_TAP, function () {
                this.gr_btn.texture = RES.getRes("tab1");
                this.bh_btn.texture = RES.getRes("tab2");
                this.gr_text.textColor = 0xFFEA70;
                this.bh_text.textColor = 0xEBC275;
                if (this.now_tab == 1) {
                    return;
                }
                this.queryGrRank();
            }, this);
        }
        //帮会排行榜
        if (!this.contentview.contains(this.bh_Container)) {
            var bh_Container = new egret.DisplayObjectContainer;
            this.contentview.addChild(bh_Container);
            this.bh_Container = bh_Container;
            var bh_btn = utils.createBitmapByName("tab2");
            bh_btn.x = gr_btn.x + gr_btn.width + 30;
            bh_btn.y = 210;
            bh_btn.touchEnabled = true;
            bh_Container.addChild(bh_btn);
            this.bh_btn = bh_btn;
            var bh_text = utils.createTextField();
            bh_text.x = bh_btn.x;
            bh_text.width = bh_btn.width;
            bh_text.y = 210;
            bh_text.height = (bh_btn.width * 66) / 190;
            bh_text.textAlign = "center";
            bh_text.verticalAlign = egret.VerticalAlign.MIDDLE;
            bh_text.text = "帮会积分榜";
            bh_text.size = 30;
            bh_text.textColor = 0xEBC275;
            bh_text.stroke = 2;
            bh_text.bold = true;
            bh_text.strokeColor = 0x6A410D;
            bh_Container.addChild(bh_text);
            this.bh_text = bh_text;
            bh_Container.touchEnabled = true;
            bh_Container.addEventListener(egret.TouchEvent.TOUCH_TAP, function () {
                this.bh_btn.texture = RES.getRes("tab1");
                this.gr_btn.texture = RES.getRes("tab2");
                this.bh_text.textColor = 0xFFEA70;
                this.gr_text.textColor = 0xEBC275;
                if (this.now_tab == 2) {
                    return;
                }
                this.queryBhRank();
            }, this);
        }
        //列表
        if (!this.contentview.contains(this.tableView)) {
            var tableView = new TableView.TableView();
            tableView.height = this.bg_jf.height - 15;
            tableView.scrollPolicyH = "false";
            // tableView.scrollPolicyV = "false";  
            tableView.width = this.bg_jf.width;
            tableView.anchorOffsetX = tableView.width / 2;
            tableView.x = (this.width) / 2;
            tableView.y = this.bg_jf.y + 6;
            this.tableView = tableView;
            this.contentview.addChild(this.tableView);
        }
        if (!this.contentview.contains(this.emptyLabel_img)) {
            this.emptyLabel_img = utils.createBitmapByName("dj_icon");
            this.emptyLabel_img.x = (this.width - this.emptyLabel_img.width) / 2;
            this.emptyLabel_img.y = (this.height - this.emptyLabel_img.height) / 2;
            this.contentview.addChild(this.emptyLabel_img);
            this.emptyLabel_img.visible = false;
        }
        if (!this.contentview.contains(this.emptyLabel_text)) {
            this.emptyLabel_text = new BaseTextField();
            this.emptyLabel_text.text = "暂无数据!";
            this.emptyLabel_text.width = this.width;
            this.emptyLabel_text.y = this.contentview.y + this.emptyLabel_img.height / 2 + 10;
            this.emptyLabel_text.textColor = 0xc19b61;
            this.emptyLabel_text.visible = false;
            this.emptyLabel_text.textAlign = "center";
            this.contentview.addChild(this.emptyLabel_text);
        }
        if (!this.contentview.contains(this._timeLabel)) {
            var timeLabel = new BaseTextField();
            timeLabel.height = 110;
            timeLabel.textAlign = egret.HorizontalAlign.CENTER;
            timeLabel.textColor = 0x7C552C;
            timeLabel.lineSpacing = 10;
            timeLabel.width = (this.contentview.width);
            timeLabel.x = (this.width - timeLabel.width) / 2;
            timeLabel.y = this.tableView.y + this.tableView.height + 10;
            timeLabel.text = "下次活动开启时间\n";
            timeLabel.verticalAlign = egret.VerticalAlign.MIDDLE;
            timeLabel.size = 26;
            timeLabel.bold = true;
            this._timeLabel = timeLabel;
            this.contentview.addChild(this._timeLabel);
        }
        if (this.now_tab == 2) {
            this.queryBhRank();
        }
        else {
            this.queryGrRank();
        }
        this.addAnimation();
    };
    // 添加动画
    LastJiFenRankView.prototype.addAnimation = function () {
        this.contentview.scaleX = this.contentview.scaleY = 0;
        egret.Tween.removeTweens(this.contentview);
        egret.Tween.get(this.contentview).to({ scaleX: 1, scaleY: 1 }, 500, egret.Ease.backOut);
    };
    /**
     * 创建个人排行榜
     */
    LastJiFenRankView.prototype.createGrJiFenView = function (data) {
        this.emptyLabel_text.visible = false;
        this.emptyLabel_img.visible = false;
        var dataSource = data.list;
        this.tableView.dataSource = dataSource;
        this.tableView.itemRenderer = JiFenCell;
        JiFenCell.CELLWIDTH = this.tableView.width;
        JiFenCell.jfView = this;
        if (dataSource.length <= 0) {
            this.emptyLabel_text.visible = true;
            this.emptyLabel_img.visible = true;
        }
        else {
            for (var i = 0; i < dataSource.length; i++) {
                this.props_arr.gr.push(dataSource[i].props);
            }
        }
        if (this.contentview.contains(this.my_rank)) {
            this.contentview.removeChild(this.my_rank);
        }
    };
    /**
     * 创建帮会排行榜
     */
    LastJiFenRankView.prototype.createBhJiFenView = function (data) {
        this.emptyLabel_text.visible = false;
        this.emptyLabel_img.visible = false;
        var dataSource = data.list;
        this.tableView.dataSource = dataSource;
        this.tableView.itemRenderer = BhJiFenCell;
        BhJiFenCell.CELLWIDTH = this.tableView.width;
        BhJiFenCell.jfView = this;
        if (dataSource.length <= 0) {
            this.emptyLabel_text.visible = true;
            this.emptyLabel_img.visible = true;
        }
        else {
            for (var i = 0; i < dataSource.length; i++) {
                this.props_arr.bh.push(dataSource[i].props);
            }
        }
        //帮会排名
        if (this.contentview.contains(this.my_rank)) {
            this.contentview.removeChild(this.my_rank);
        }
    };
    LastJiFenRankView.prototype.showAwardList = function (index, x, evt, type) {
        if (this.contentview.contains(this.bgMaskAward)) {
            this.contentview.removeChild(this.bgMaskAward);
        }
        this.bgMaskAward = new egret.Shape();
        this.bgMaskAward.graphics.beginFill(0x000000, 0);
        this.bgMaskAward.graphics.drawRect(0, 0, this.width, this.height);
        this.bgMaskAward.graphics.endFill();
        this.bgMaskAward.touchEnabled = true;
        this.contentview.addChild(this.bgMaskAward);
        this.bgMaskAward.addEventListener(egret.TouchEvent.TOUCH_TAP, function () {
            this.bgMaskAward.visible = false;
            this.award_list_view.visible = false;
        }, this);
        if (this.contentview.contains(this.award_list_view)) {
            this.contentview.removeChild(this.award_list_view);
        }
        this.award_list_view = new egret.DisplayObjectContainer;
        var bg = utils.createBitmapByName("award_bg_png");
        bg.width = this.bg_jf.width;
        this.award_list_view.addChild(bg);
        this.contentview.addChild(this.award_list_view);
        // this.award_list_view.y = y + this.tableView.y;
        this.award_list_view.y = evt.stageY;
        this.award_list_view.x = x - 440;
        this.award_list_view.height = bg.height;
        var data = this.props_arr[type][index - 1];
        bg.height = 130 * (Math.floor(data.length / 7) + 1) + 20;
        var width = (bg.width) / 6;
        var height = 130;
        var _loop_2 = function (i) {
            view = new egret.DisplayObjectContainer;
            view.width = width;
            view.height = height;
            view.anchorOffsetX = view.width / 2;
            view.anchorOffsetY = view.height / 2;
            if (i % 6 == 0) {
                view.x = width * 5 + (width / 2);
                view.y = 130 * (Math.floor(i / 6) - 1) + view.height / 2;
            }
            else {
                view.x = width * (i % 6 - 1) + (width / 2);
                view.y = 130 * (Math.floor(i / 6)) + view.height / 2;
            }
            img = new eui.Image();
            var item = data[i - 1];
            img.width = width * 0.75;
            img.height = width * 0.75;
            img.anchorOffsetX = img.width / 2;
            img.anchorOffsetY = img.height / 2;
            img.y = view.height / 2;
            img.x = view.width / 2;
            img.source = item.prop_img;
            view.addChild(img);
            text = utils.createTextField();
            text.size = 16;
            text.textColor = 0x6A410D;
            text.bold = true;
            // text.x = (view.width - text.width)/2;
            text.y = img.y + img.height / 2 + 5;
            text.width = view.width;
            if (item.count > 1) {
                text.text = item.prop_name + " x" + item.count;
            }
            else {
                text.text = item.prop_name;
            }
            view.addChild(text);
            this_2.award_list_view.addChild(view);
            view.addEventListener(egret.TouchEvent.TOUCH_TAP, function () {
                var data_tool = {};
                if (item.type == 1) {
                    data_tool = {
                        "img": item.prop_img,
                        "name": item.prop_name,
                        "desc": item.prop_desc,
                        "type": item.type
                    };
                }
                else {
                    data_tool = {
                        "img": item.prop_img,
                        "name": item.prop_name,
                        "desc": item.prop_desc,
                        "type": item.type,
                        "parent_img": item.parent_img,
                        "parent_name": item.parent_name,
                        "parent_desc": item.parent_desc,
                    };
                }
                Main.showTooInfoView(data_tool);
            }, view);
        };
        var this_2 = this, view, img, text;
        for (var i = 1; i <= data.length; i++) {
            _loop_2(i);
        }
    };
    // 更新时间
    LastJiFenRankView.prototype.updateDate = function (next, date) {
        if (next) {
            this._timeLabel.text = "下次活动开启时间\n" + next;
        }
        else {
            this._timeLabel.text = '';
        }
        if (date) {
            this.todayLabel.text = date;
            this.todayShape.visible = true;
            this.title.y = 90;
        }
        else {
            this.todayLabel.text = '';
            this.todayShape.visible = false;
            this.title.y = 100;
        }
    };
    return LastJiFenRankView;
}(BaseView));
__reflect(LastJiFenRankView.prototype, "LastJiFenRankView");
var CellHeaderView = (function (_super) {
    __extends(CellHeaderView, _super);
    function CellHeaderView() {
        var _this = _super.call(this) || this;
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.viewDidLoad, _this);
        return _this;
    }
    CellHeaderView.prototype.viewDidLoad = function () {
        // 背景
        if (!this.contains(this.bg))
            this.addChild(this.bg);
        // 头像
        if (!this.contains(this.iconImg))
            this.addChild(this.iconImg);
        // 等级
        if (!this.contains(this.levelImg))
            this.addChild(this.levelImg);
    };
    Object.defineProperty(CellHeaderView.prototype, "level", {
        /*********************************************** setter **********************************************************/
        set: function (value) {
            this._level = value;
            this.levelImg.texture = RES.getRes('levelname' + value);
            this.bg.texture = RES.getRes('level' + value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(CellHeaderView.prototype, "iconURL", {
        set: function (value) {
            this._iconURL = value;
            this.iconImg.source = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(CellHeaderView.prototype, "isHeader", {
        set: function (value) {
            this._isHeader = value;
            if (value) {
                if (!this.contains(this.headerImg))
                    this.addChild(this.headerImg);
            }
            else {
                if (this.contains(this.headerImg))
                    this.removeChild(this.headerImg);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(CellHeaderView.prototype, "headerImg", {
        /*********************************************** getter **********************************************************/
        get: function () {
            if (!this._headerImg) {
                var headerImg = utils.createBitmapByName('bz', { width: this.width * 0.6 });
                this._headerImg = headerImg;
            }
            return this._headerImg;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(CellHeaderView.prototype, "iconImg", {
        get: function () {
            if (!this._iconImg) {
                var iconImg = new eui.Image();
                iconImg.source = RES.getRes(this.iconURL || 'face');
                var margin = 6;
                iconImg.width = this.width - 2 * margin;
                iconImg.height = this.height - 2 * margin;
                iconImg.x = margin;
                iconImg.y = margin;
                var mask = utils.drawRound(iconImg.x, iconImg.y, iconImg.width, iconImg.height, 0x000, 10);
                this.addChild(mask);
                iconImg.mask = mask;
                this._iconImg = iconImg;
            }
            return this._iconImg;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(CellHeaderView.prototype, "bg", {
        get: function () {
            if (!this._bg) {
                var bg = new egret.Bitmap();
                var level = this.level || 1;
                bg.texture = RES.getRes('level' + level);
                bg.width = this.width;
                bg.height = this.height;
                this._bg = bg;
            }
            return this._bg;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(CellHeaderView.prototype, "levelImg", {
        get: function () {
            if (!this._levelImg) {
                var level = this.level || 1;
                var levelImg = utils.createBitmapByName('levelname' + level, { width: this.width + 20 });
                levelImg.y = this.height - levelImg.height;
                this._levelImg = levelImg;
            }
            return this._levelImg;
        },
        enumerable: true,
        configurable: true
    });
    return CellHeaderView;
}(egret.DisplayObjectContainer));
__reflect(CellHeaderView.prototype, "CellHeaderView");
var EmptyView = (function (_super) {
    __extends(EmptyView, _super);
    function EmptyView() {
        var _this = _super.call(this) || this;
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.viewDidLoad, _this);
        return _this;
    }
    EmptyView.prototype.viewDidLoad = function () {
        // 1.图标
        if (!this.contains(this.iconImg))
            this.addChild(this.iconImg);
        // 2.提示
        if (!this.contains(this.label))
            this.addChild(this.label);
    };
    Object.defineProperty(EmptyView.prototype, "label", {
        /*********************************************** getter **********************************************************/
        get: function () {
            if (!this._label) {
                var label = new BaseTextField();
                label.text = "暂无数据";
                label.width = this.width;
                label.textColor = 0xb88b39;
                label.y = utils.getMaxY(this.iconImg) + 10;
                label.textAlign = egret.HorizontalAlign.CENTER;
                this._label = label;
            }
            return this._label;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(EmptyView.prototype, "iconImg", {
        get: function () {
            if (!this._iconImg) {
                var iconImg = utils.createBitmapByName('dj_icon');
                iconImg.x = (this.width - iconImg.width) / 2.0;
                this._iconImg = iconImg;
            }
            return this._iconImg;
        },
        enumerable: true,
        configurable: true
    });
    return EmptyView;
}(egret.DisplayObjectContainer));
__reflect(EmptyView.prototype, "EmptyView");
var LastJiFenBangCell = (function (_super) {
    __extends(LastJiFenBangCell, _super);
    function LastJiFenBangCell() {
        var _this = _super.call(this) || this;
        _this.height = _this.minCellHeight;
        _this.width = LastJiFenPersonCell.WIDTH;
        return _this;
    }
    LastJiFenBangCell.prototype.dataChanged = function () {
        var data = this.data;
        var index = data['rank'];
        // 1. 背景
        this.bg.texture = RES.getRes('hi_rank_cell' + index);
        // 2. 名次
        this.indexImg.texture = RES.getRes(index.toString());
        // 3.头像等级
        this.headerImg.iconURL = data['head_url'];
        this.headerImg.level = data['level_no'];
        this.headerImg.isHeader = true;
        // 4.昵称
        this.nicknameLabel.text = "帮主:" + data['nickname'] || "";
        // 5.帮会名
        this.bangnameLabel.text = data['gang_name'] || "无";
        // 6.积分
        this.codeLabel.text = data['total_score'];
        var realCodeWidth = this.codeLabel.strWidth;
        if (realCodeWidth + 2 * 10 > this.minCodeBgWidth) {
            this.updateCode(realCodeWidth + 2 * 10);
        }
        else {
            this.updateCode(this.minCodeBgWidth);
        }
        // 积分宽度确定了 那么帮派名和人名的宽度也确定了
        this.updateNameFrames();
        // 7.奖品
        var awards = data['props'];
        // 8. 根据奖品数量自适应高度
        if (awards == undefined || awards.length == 0) {
            this.height = this.minCellHeight;
            if (this.contains(this.awardsView))
                this.removeChild(this.awardsView);
        }
        else {
            if (!this.contains(this.awardsView))
                this.addChild(this.awardsView);
            this.awardsView.awards = awards;
            this.awardsView.reloadData();
            this.height = this.minCellHeight + 20 + this.awardsView.height;
        }
        this.bg.height = this.bgH;
    };
    LastJiFenBangCell.prototype.createChildren = function () {
        // 背景
        if (!this.contains(this.bg))
            this.addChild(this.bg);
        // 名次
        if (!this.contains(this.indexImg))
            this.addChild(this.indexImg);
        // 帮会图标
        if (!this.contains(this.bangImg))
            this.addChild(this.bangImg);
        // 帮会名
        if (!this.contains(this.bangnameLabel))
            this.addChild(this.bangnameLabel);
        // 头像
        if (!this.contains(this.headerImg))
            this.addChild(this.headerImg);
        // 昵称
        if (!this.contains(this.nicknameLabel))
            this.addChild(this.nicknameLabel);
        // 积分背景
        if (!this.contains(this.codeBg))
            this.addChild(this.codeBg);
        // 积分标题
        if (!this.contains(this.codeTitleLabel))
            this.addChild(this.codeTitleLabel);
        // 积分
        if (!this.contains(this.codeLabel))
            this.addChild(this.codeLabel);
    };
    /*********************************************** private **********************************************************/
    // 自适应宽度积分
    LastJiFenBangCell.prototype.updateCode = function (width) {
        this.codeLabel.width = width;
        this.codeBg.width = this.codeLabel.width;
        this.codeTitleLabel.width = this.codeLabel.width;
        this.codeBg.x = this.width - this.codeBg.width - 10;
        this.codeTitleLabel.x = this.codeBg.x;
        this.codeLabel.x = this.codeBg.x;
    };
    LastJiFenBangCell.prototype.updateNameFrames = function () {
        this.nicknameLabel.width = this.codeBg.x - this.nicknameLabel.x - 10;
        this.bangnameLabel.width = this.codeBg.x - this.bangnameLabel.x - 10;
    };
    Object.defineProperty(LastJiFenBangCell.prototype, "awardsView", {
        /*********************************************** getter **********************************************************/
        get: function () {
            if (!this._awardsView) {
                var awardsView = new LastJiFenCellAwardView();
                awardsView.x = 10;
                awardsView.width = this.width - 2 * awardsView.x;
                awardsView.y = utils.getMaxY(this.indexImg) + 20;
                this._awardsView = awardsView;
            }
            return this._awardsView;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenBangCell.prototype, "minCellHeight", {
        get: function () {
            return 160;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenBangCell.prototype, "codeLabel", {
        get: function () {
            if (!this._codeLabel) {
                var codeLabel = new BaseTextField();
                codeLabel.textColor = 0xFED253;
                codeLabel.size = 28;
                codeLabel.width = this.codeBg.width;
                codeLabel.height = 30;
                codeLabel.textAlign = egret.HorizontalAlign.CENTER;
                codeLabel.verticalAlign = egret.VerticalAlign.MIDDLE;
                codeLabel.italic = true;
                codeLabel.bold = true;
                codeLabel.x = this.codeBg.x;
                codeLabel.y = this.codeBg.y;
                this._codeLabel = codeLabel;
            }
            return this._codeLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenBangCell.prototype, "codeTitleLabel", {
        get: function () {
            if (!this._codeTitleLabel) {
                var codeTitleLabel = new BaseTextField();
                codeTitleLabel.textColor = 0xffffff;
                codeTitleLabel.size = 22;
                codeTitleLabel.width = this.codeBg.width;
                codeTitleLabel.text = "帮会积分";
                codeTitleLabel.textAlign = egret.HorizontalAlign.CENTER;
                codeTitleLabel.x = this.codeBg.x;
                codeTitleLabel.y = this.codeBg.y - codeTitleLabel.height - 5;
                codeTitleLabel.italic = true;
                this._codeTitleLabel = codeTitleLabel;
            }
            return this._codeTitleLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenBangCell.prototype, "codeBg", {
        get: function () {
            if (!this._codeBg) {
                var codeBg = utils.createBitmapByName('jfbg', { offsetY: 0.5 });
                codeBg.scale9Grid = new egret.Rectangle(26, 26, 72, 36);
                codeBg.x = this.width - codeBg.width - 10;
                codeBg.y = this.indexImg.y;
                this._codeBg = codeBg;
            }
            return this._codeBg;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenBangCell.prototype, "minCodeBgWidth", {
        get: function () {
            return 126;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenBangCell.prototype, "bangnameLabel", {
        get: function () {
            if (!this._bangnameLabel) {
                var bangnameLabel = new BaseTextField();
                bangnameLabel.textColor = 0xFFFFFF;
                bangnameLabel.stroke = 2;
                bangnameLabel.strokeColor = 0x6D410B;
                bangnameLabel.height = 30;
                bangnameLabel.verticalAlign = egret.VerticalAlign.MIDDLE;
                bangnameLabel.anchorOffsetY = bangnameLabel.height / 2.0;
                bangnameLabel.x = utils.getMaxX(this.bangImg) + 5;
                bangnameLabel.y = this.bangImg.y;
                bangnameLabel.size = 26;
                bangnameLabel.bold = true;
                this._bangnameLabel = bangnameLabel;
            }
            return this._bangnameLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenBangCell.prototype, "bangImg", {
        get: function () {
            if (!this._bangImg) {
                var bangImg = utils.createBitmapByName('bhicon', { offsetY: 0.5 });
                bangImg.x = utils.getMaxX(this.indexImg) + 5;
                bangImg.y = this.indexImg.y + bangImg.anchorOffsetY - bangImg.height - 10;
                this._bangImg = bangImg;
            }
            return this._bangImg;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenBangCell.prototype, "nicknameLabel", {
        get: function () {
            if (!this._nicknameLabel) {
                var nicknameLabel = new BaseTextField();
                nicknameLabel.height = 30;
                nicknameLabel.verticalAlign = egret.VerticalAlign.MIDDLE;
                nicknameLabel.anchorOffsetY = nicknameLabel.height / 2.0;
                nicknameLabel.textColor = 0x6C400B;
                nicknameLabel.x = utils.getMaxX(this.headerImg) + 5;
                nicknameLabel.y = this.headerImg.y;
                nicknameLabel.size = 24;
                nicknameLabel.bold = true;
                this._nicknameLabel = nicknameLabel;
            }
            return this._nicknameLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenBangCell.prototype, "headerImg", {
        get: function () {
            if (!this._headerImg) {
                var headerImg = new CellHeaderView();
                headerImg.width = headerImg.height = 60;
                headerImg.anchorOffsetY = headerImg.height / 2.0;
                headerImg.x = this.bangImg.x;
                headerImg.y = this.indexImg.y + headerImg.anchorOffsetY - 5;
                this._headerImg = headerImg;
            }
            return this._headerImg;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenBangCell.prototype, "indexImg", {
        get: function () {
            if (!this._indexImg) {
                var indexImg = utils.createBitmapByName('1', { offsetY: 0.5 });
                indexImg.x = 10;
                indexImg.y = 80;
                this._indexImg = indexImg;
            }
            return this._indexImg;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenBangCell.prototype, "bg", {
        get: function () {
            if (!this._bg) {
                var bg = utils.createBitmapByName("hi_rank_cell3", { width: this.width });
                bg.scale9Grid = new egret.Rectangle(158, 14, 206, 24);
                bg.y = this.bgY;
                bg.height = this.bgH;
                this._bg = bg;
            }
            return this._bg;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenBangCell.prototype, "bgH", {
        get: function () {
            return this.height - 2 * this.bgY;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenBangCell.prototype, "bgY", {
        get: function () {
            return 5;
        },
        enumerable: true,
        configurable: true
    });
    LastJiFenBangCell.WIDTH = 0;
    return LastJiFenBangCell;
}(eui.ItemRenderer));
__reflect(LastJiFenBangCell.prototype, "LastJiFenBangCell");
var LastJiFenCellAwardView = (function (_super) {
    __extends(LastJiFenCellAwardView, _super);
    function LastJiFenCellAwardView() {
        var _this = _super.call(this) || this;
        _this.awards = []; // 奖品数组
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.viewDidLoad, _this);
        return _this;
    }
    LastJiFenCellAwardView.prototype.viewDidLoad = function () {
        this.addEventListener(egret.Event.REMOVED_FROM_STAGE, this.viewDidDisappear, this);
    };
    LastJiFenCellAwardView.prototype.viewDidDisappear = function () {
        this.removeEventListener(egret.Event.REMOVED_FROM_STAGE, this.viewDidDisappear, this);
        // 1.清空视图
        this.removeChildren();
    };
    /*********************************************** public **********************************************************/
    LastJiFenCellAwardView.prototype.reloadData = function () {
        this.removeChildren();
        // 1.背景
        if (!this.contains(this.bg))
            this.addChild(this.bg);
        this.updateSubViews();
    };
    /*********************************************** private **********************************************************/
    LastJiFenCellAwardView.prototype.updateSubViews = function () {
        var length = this.awards.length;
        var obj = undefined;
        var lineH = 1;
        var awardView = undefined;
        var shape = undefined;
        var totalH = 5;
        for (var i = 0; i < length; i++) {
            obj = this.awards[i];
            // var awardView = new LastJiFenSingleAwardView();
            awardView = LastJiFenSingleAwardView.getObj();
            awardView.x = 10;
            awardView.width = this.width - 2 * awardView.x;
            awardView.y = totalH;
            awardView.iconUrl = obj.prop_img;
            awardView.name = obj.prop_name;
            awardView.describtion = obj.prop_desc;
            awardView.num = obj.count;
            this.addChild(awardView);
            totalH += awardView.height;
            if (i == length - 1) {
                this.height = utils.getMaxY(awardView);
                this.bg.height = this.height;
                return;
            }
            shape = new egret.Shape();
            shape.x = awardView.x;
            shape.y = awardView.y + awardView.height;
            shape.graphics.lineStyle(lineH, 0xffffff, 0.3, null, null, null, null, null, [20, 10]);
            shape.graphics.moveTo(0, 0);
            shape.graphics.lineTo(awardView.width, 0);
            shape.graphics.endFill();
            totalH += lineH;
            this.addChild(shape);
        }
    };
    Object.defineProperty(LastJiFenCellAwardView.prototype, "bg", {
        /*********************************************** getter **********************************************************/
        get: function () {
            if (!this._bg) {
                var bg = utils.createBitmapByName('bg_bh', { width: this.width });
                bg.scale9Grid = new egret.Rectangle(44, 28, 293, 114);
                this._bg = bg;
            }
            return this._bg;
        },
        enumerable: true,
        configurable: true
    });
    return LastJiFenCellAwardView;
}(egret.DisplayObjectContainer));
__reflect(LastJiFenCellAwardView.prototype, "LastJiFenCellAwardView");
var LastJiFenPersonCell = (function (_super) {
    __extends(LastJiFenPersonCell, _super);
    function LastJiFenPersonCell() {
        var _this = _super.call(this) || this;
        _this.height = _this.minCellHeight;
        _this.width = LastJiFenPersonCell.WIDTH;
        return _this;
    }
    LastJiFenPersonCell.prototype.dataChanged = function () {
        var data = this.data;
        var index = data['rank'];
        // 1. 背景
        this.bg.texture = RES.getRes('hi_rank_cell' + index);
        // 2. 名次
        this.indexImg.texture = RES.getRes(index.toString());
        // 3.头像等级
        this.headerImg.iconURL = data['head_url'];
        this.headerImg.level = data['level_no'];
        // 4.昵称
        this.nicknameLabel.text = data['nickname'];
        // 5.帮会名
        this.bangnameLabel.text = data['gang_name'] || "无";
        // 6.积分
        this.codeLabel.text = data['total_score'];
        var realCodeWidth = this.codeLabel.strWidth;
        if (realCodeWidth + 2 * 10 > this.minCodeBgWidth) {
            this.updateCode(realCodeWidth + 2 * 10);
        }
        else {
            this.updateCode(this.minCodeBgWidth);
        }
        // 积分宽度确定了 那么帮派名和人名的宽度也确定了
        this.updateNameFrames();
        // 7.奖品
        var awards = data['props'];
        // 8. 根据奖品数量自适应高度
        if (awards == undefined || awards.length == 0) {
            this.height = this.minCellHeight;
            if (this.contains(this.awardsView))
                this.removeChild(this.awardsView);
        }
        else {
            if (!this.contains(this.awardsView))
                this.addChild(this.awardsView);
            this.awardsView.awards = awards;
            this.awardsView.reloadData();
            this.height = this.minCellHeight + 20 + this.awardsView.height;
        }
        this.bg.height = this.bgH;
    };
    LastJiFenPersonCell.prototype.createChildren = function () {
        // 背景
        if (!this.contains(this.bg))
            this.addChild(this.bg);
        // 名次
        if (!this.contains(this.indexImg))
            this.addChild(this.indexImg);
        // 头像
        if (!this.contains(this.headerImg))
            this.addChild(this.headerImg);
        // 昵称
        if (!this.contains(this.nicknameLabel))
            this.addChild(this.nicknameLabel);
        // 积分背景
        if (!this.contains(this.codeBg))
            this.addChild(this.codeBg);
        // 帮会图标
        if (!this.contains(this.bangImg))
            this.addChild(this.bangImg);
        // 帮会名
        if (!this.contains(this.bangnameLabel))
            this.addChild(this.bangnameLabel);
        // 积分标题
        if (!this.contains(this.codeTitleLabel))
            this.addChild(this.codeTitleLabel);
        // 积分
        if (!this.contains(this.codeLabel))
            this.addChild(this.codeLabel);
    };
    /*********************************************** private **********************************************************/
    // 自适应宽度积分
    LastJiFenPersonCell.prototype.updateCode = function (width) {
        this.codeLabel.width = width;
        this.codeBg.width = this.codeLabel.width;
        this.codeTitleLabel.width = this.codeLabel.width;
        this.codeBg.x = this.width - this.codeBg.width - 10;
        this.codeTitleLabel.x = this.codeBg.x;
        this.codeLabel.x = this.codeBg.x;
    };
    LastJiFenPersonCell.prototype.updateNameFrames = function () {
        this.nicknameLabel.width = this.codeBg.x - this.nicknameLabel.x - 10;
        this.bangnameLabel.width = this.codeBg.x - this.bangnameLabel.x - 10;
    };
    Object.defineProperty(LastJiFenPersonCell.prototype, "awardsView", {
        /*********************************************** getter **********************************************************/
        get: function () {
            if (!this._awardsView) {
                var awardsView = new LastJiFenCellAwardView();
                awardsView.x = 10;
                awardsView.width = this.width - 2 * awardsView.x;
                awardsView.y = utils.getMaxY(this.indexImg) + 20;
                this._awardsView = awardsView;
            }
            return this._awardsView;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenPersonCell.prototype, "minCellHeight", {
        get: function () {
            return 160;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenPersonCell.prototype, "codeLabel", {
        get: function () {
            if (!this._codeLabel) {
                var codeLabel = new BaseTextField();
                codeLabel.textColor = 0xFED253;
                codeLabel.size = 28;
                codeLabel.width = this.codeBg.width;
                codeLabel.height = 30;
                codeLabel.textAlign = egret.HorizontalAlign.CENTER;
                codeLabel.verticalAlign = egret.VerticalAlign.MIDDLE;
                codeLabel.italic = true;
                codeLabel.bold = true;
                codeLabel.x = this.codeBg.x;
                codeLabel.y = this.codeBg.y;
                this._codeLabel = codeLabel;
            }
            return this._codeLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenPersonCell.prototype, "codeTitleLabel", {
        get: function () {
            if (!this._codeTitleLabel) {
                var codeTitleLabel = new BaseTextField();
                codeTitleLabel.textColor = 0xffffff;
                codeTitleLabel.size = 22;
                codeTitleLabel.width = this.codeBg.width;
                codeTitleLabel.text = "个人积分";
                codeTitleLabel.textAlign = egret.HorizontalAlign.CENTER;
                codeTitleLabel.x = this.codeBg.x;
                codeTitleLabel.y = this.codeBg.y - codeTitleLabel.height - 5;
                codeTitleLabel.italic = true;
                this._codeTitleLabel = codeTitleLabel;
            }
            return this._codeTitleLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenPersonCell.prototype, "codeBg", {
        get: function () {
            if (!this._codeBg) {
                var codeBg = utils.createBitmapByName('jfbg', { offsetY: 0.5 });
                codeBg.scale9Grid = new egret.Rectangle(26, 26, 72, 36);
                codeBg.x = this.width - codeBg.width - 10;
                codeBg.y = this.indexImg.y;
                this._codeBg = codeBg;
            }
            return this._codeBg;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenPersonCell.prototype, "minCodeBgWidth", {
        get: function () {
            return 126;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenPersonCell.prototype, "bangnameLabel", {
        get: function () {
            if (!this._bangnameLabel) {
                var bangnameLabel = new BaseTextField();
                bangnameLabel.textColor = 0xFFFFFF;
                bangnameLabel.stroke = 2;
                bangnameLabel.strokeColor = 0x6D410B;
                bangnameLabel.height = 30;
                bangnameLabel.verticalAlign = egret.VerticalAlign.MIDDLE;
                bangnameLabel.anchorOffsetY = bangnameLabel.height / 2.0;
                bangnameLabel.x = utils.getMaxX(this.bangImg) + 5;
                bangnameLabel.y = this.bangImg.y;
                bangnameLabel.size = 24;
                bangnameLabel.bold = true;
                this._bangnameLabel = bangnameLabel;
            }
            return this._bangnameLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenPersonCell.prototype, "bangImg", {
        get: function () {
            if (!this._bangImg) {
                var bangImg = utils.createBitmapByName('bhicon', { offsetY: 0.5 });
                bangImg.x = this.headerImg.x;
                bangImg.y = this.indexImg.y + bangImg.anchorOffsetY + 5 + 10;
                this._bangImg = bangImg;
            }
            return this._bangImg;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenPersonCell.prototype, "nicknameLabel", {
        get: function () {
            if (!this._nicknameLabel) {
                var nicknameLabel = new BaseTextField();
                nicknameLabel.height = 30;
                nicknameLabel.verticalAlign = egret.VerticalAlign.MIDDLE;
                nicknameLabel.anchorOffsetY = nicknameLabel.height / 2.0;
                nicknameLabel.textColor = 0x6C400B;
                nicknameLabel.x = utils.getMaxX(this.headerImg) + 5;
                nicknameLabel.y = this.headerImg.y;
                nicknameLabel.bold = true;
                nicknameLabel.size = 26;
                this._nicknameLabel = nicknameLabel;
            }
            return this._nicknameLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenPersonCell.prototype, "headerImg", {
        get: function () {
            if (!this._headerImg) {
                var headerImg = new CellHeaderView();
                headerImg.width = headerImg.height = 60;
                headerImg.anchorOffsetY = headerImg.height / 2.0;
                headerImg.x = utils.getMaxX(this.indexImg) + 5;
                headerImg.y = this.indexImg.y + 10 - headerImg.height + headerImg.anchorOffsetY;
                this._headerImg = headerImg;
            }
            return this._headerImg;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenPersonCell.prototype, "indexImg", {
        get: function () {
            if (!this._indexImg) {
                var indexImg = utils.createBitmapByName('1', { offsetY: 0.5 });
                indexImg.x = 10;
                indexImg.y = 80;
                this._indexImg = indexImg;
            }
            return this._indexImg;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenPersonCell.prototype, "bg", {
        get: function () {
            if (!this._bg) {
                var bg = utils.createBitmapByName("hi_rank_cell3", { width: this.width });
                bg.scale9Grid = new egret.Rectangle(158, 14, 206, 24);
                bg.y = this.bgY;
                bg.height = this.bgH;
                this._bg = bg;
            }
            return this._bg;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenPersonCell.prototype, "bgH", {
        get: function () {
            return this.height - 2 * this.bgY;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenPersonCell.prototype, "bgY", {
        get: function () {
            return 5;
        },
        enumerable: true,
        configurable: true
    });
    LastJiFenPersonCell.WIDTH = 0;
    return LastJiFenPersonCell;
}(eui.ItemRenderer));
__reflect(LastJiFenPersonCell.prototype, "LastJiFenPersonCell");
var LastJiFenSingleAwardView = (function (_super) {
    __extends(LastJiFenSingleAwardView, _super);
    function LastJiFenSingleAwardView() {
        var _this = _super.call(this) || this;
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.viewDidLoad, _this);
        return _this;
    }
    LastJiFenSingleAwardView.prototype.viewDidLoad = function () {
        this.addEventListener(egret.Event.REMOVED_FROM_STAGE, this.viewDidDisappear, this);
        // 1.图片
        if (!this.contains(this.iconImg))
            this.addChild(this.iconImg);
        // 2.名称
        if (!this.contains(this.nameLabel))
            this.addChild(this.nameLabel);
        // 3. 描述
        if (!this.contains(this.descLabel))
            this.addChild(this.descLabel);
        // 4. 数量
        if (!this.contains(this.numLabel))
            this.addChild(this.numLabel);
        // 刷新自身的高度
        this.height = utils.getMaxY(this.descLabel) + this.nameLabel.y;
        this.iconImg.y = this.height / 2.0;
    };
    LastJiFenSingleAwardView.prototype.viewDidDisappear = function () {
        this.removeEventListener(egret.Event.REMOVED_FROM_STAGE, this.viewDidDisappear, this);
        LastJiFenSingleAwardView.pool.push(this);
    };
    /*********************************************** public **********************************************************/
    LastJiFenSingleAwardView.getObj = function () {
        var obj = this.pool.shift();
        if (!obj) {
            obj = new LastJiFenSingleAwardView();
        }
        return obj;
    };
    /*********************************************** private **********************************************************/
    LastJiFenSingleAwardView.prototype.receiveImgAction = function () {
        if (!this.iconImg.texture)
            return;
        this.iconImg.height = this.iconImg.width * this.iconImg.texture.textureHeight / this.iconImg.texture.textureWidth;
        this.iconImg.anchorOffsetY = this.iconImg.height / 2.0;
        this.numLabel.y = utils.getMaxY(this.iconImg) - this.numLabel.height - 5;
    };
    Object.defineProperty(LastJiFenSingleAwardView.prototype, "iconUrl", {
        /*********************************************** setter **********************************************************/
        set: function (value) {
            this.iconImg.source = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenSingleAwardView.prototype, "name", {
        set: function (value) {
            this.nameLabel.text = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenSingleAwardView.prototype, "describtion", {
        set: function (value) {
            this.descLabel.text = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenSingleAwardView.prototype, "num", {
        set: function (value) {
            this.numLabel.text = "X" + value;
            this.numLabel.x = utils.getMaxX(this.iconImg) - this.numLabel.width + 10;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenSingleAwardView.prototype, "numLabel", {
        /*********************************************** getter **********************************************************/
        get: function () {
            if (!this._numLabel) {
                var numLabel = new BaseTextField();
                numLabel.textColor = 0xFED721;
                numLabel.strokeColor = 0x885615;
                numLabel.stroke = 2;
                numLabel.italic = true;
                numLabel.text = "X";
                numLabel.bold = true;
                numLabel.x = utils.getMaxX(this.iconImg) - numLabel.width;
                numLabel.y = utils.getMaxY(this.iconImg) - numLabel.height - 5;
                this._numLabel = numLabel;
            }
            return this._numLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenSingleAwardView.prototype, "descLabel", {
        get: function () {
            if (!this._descLabel) {
                var descLabel = new BaseTextField();
                descLabel.textColor = 0x633E0C;
                descLabel.size = 24;
                descLabel.x = this.nameLabel.x;
                descLabel.width = this.width - descLabel.x;
                descLabel.verticalAlign = egret.VerticalAlign.MIDDLE;
                descLabel.y = utils.getMaxY(this.nameLabel) + 5;
                this._descLabel = descLabel;
            }
            return this._descLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenSingleAwardView.prototype, "nameLabel", {
        get: function () {
            if (!this._nameLabel) {
                var nameLabel = new BaseTextField();
                nameLabel.textColor = 0x633E0C;
                nameLabel.size = 24;
                nameLabel.x = utils.getMaxX(this.iconImg) + 20;
                nameLabel.width = this.width - nameLabel.x;
                nameLabel.height = 30;
                nameLabel.y = 20;
                nameLabel.verticalAlign = egret.VerticalAlign.MIDDLE;
                nameLabel.bold = true;
                this._nameLabel = nameLabel;
            }
            return this._nameLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenSingleAwardView.prototype, "iconImg", {
        get: function () {
            if (!this._iconImg) {
                var iconImg = new eui.Image();
                iconImg.width = 80;
                iconImg.addEventListener(egret.Event.COMPLETE, this.receiveImgAction, this);
                iconImg.y = this.height / 2.0;
                this._iconImg = iconImg;
            }
            return this._iconImg;
        },
        enumerable: true,
        configurable: true
    });
    LastJiFenSingleAwardView.pool = [];
    return LastJiFenSingleAwardView;
}(egret.DisplayObjectContainer));
__reflect(LastJiFenSingleAwardView.prototype, "LastJiFenSingleAwardView");
var LastJiFenTabbar = (function (_super) {
    __extends(LastJiFenTabbar, _super);
    function LastJiFenTabbar() {
        var _this = _super.call(this) || this;
        _this.items = [];
        _this.bgObjs = [];
        _this.tfObjs = [];
        _this.index = 0; // 指定位于哪一个tab
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.viewDidLoad, _this);
        return _this;
    }
    LastJiFenTabbar.prototype.viewDidLoad = function () {
        this.addEventListener(egret.Event.REMOVED_FROM_STAGE, this.viewDidDisappear, this);
        this.updateViews();
        this.tapIndex(this.index);
    };
    LastJiFenTabbar.prototype.viewDidDisappear = function () {
        this.removeEventListener(egret.Event.REMOVED_FROM_STAGE, this.viewDidDisappear, this);
        // 离开视图的时候 要清空
        this.clearViews();
    };
    /*********************************************** private **********************************************************/
    LastJiFenTabbar.prototype.tapAction = function (event) {
        var index = this.getIndexInArray(event.currentTarget.text, this.items);
        if (index === false)
            return;
        if (this.index == index)
            return;
        this.index = index;
        for (var i = 0; i < this.numChildren; i++) {
            var child = this.getChildAt(i);
            if (child instanceof HIRTabbarBitmap) {
                this.updateBg(child.index === index ? 'tab1' : 'tab2', child);
            }
            else if (child instanceof BaseTextField) {
                if (child.text === event.currentTarget.text) {
                    child.textColor = 0xFDE662;
                    child.strokeColor = 0x6E4120;
                }
                else {
                    child.textColor = 0xEBC275;
                    child.strokeColor = 0x965F41;
                }
            }
        }
        if (this.callback)
            this.callback(index);
    };
    LastJiFenTabbar.prototype.tapIndex = function (index) {
        if (index >= this.items.length)
            return;
        for (var i = 0; i < this.numChildren; i++) {
            var child = this.getChildAt(i);
            if (child instanceof HIRTabbarBitmap) {
                this.updateBg(child.index === index ? 'tab1' : 'tab2', child);
            }
            else if (child instanceof BaseTextField) {
                if (child.text === this.items[index]) {
                    child.textColor = 0xFDE662;
                    child.strokeColor = 0x6E4120;
                }
                else {
                    child.textColor = 0xEBC275;
                    child.strokeColor = 0x965F41;
                }
            }
        }
        if (this.callback)
            this.callback(index);
    };
    LastJiFenTabbar.prototype.updateViews = function () {
        this.clearViews();
        var margin = 10;
        var length = this.items.length;
        if (length < 3)
            margin = 20;
        for (var i = 0; i < length; i++) {
            var bg = this.getBgObj();
            bg.x = (this.width - (bg.width * length + margin * (length - 1))) / 2.0 + bg.anchorOffsetX + i * (bg.width + margin);
            bg.index = i;
            var tf = this.getTfObj();
            tf.text = this.items[i];
            tf.x = bg.x - bg.anchorOffsetX;
            tf.width = bg.width;
            tf.height = bg.height;
            this.addChild(bg);
            this.addChild(tf);
        }
    };
    LastJiFenTabbar.prototype.getBgObj = function () {
        var bg = this.bgObjs.pop();
        if (!bg) {
            bg = new HIRTabbarBitmap();
        }
        this.updateBg('tab2', bg);
        return bg;
    };
    LastJiFenTabbar.prototype.getTfObj = function () {
        var tf = this.tfObjs.pop();
        if (!tf) {
            tf = new BaseTextField();
            tf.touchEnabled = true;
            tf.size = 25;
            tf.stroke = 2;
            tf.textAlign = egret.HorizontalAlign.CENTER;
            tf.verticalAlign = egret.VerticalAlign.MIDDLE;
            tf.addEventListener(egret.TouchEvent.TOUCH_TAP, this.tapAction, this);
        }
        tf.textColor = 0xFBEBC7;
        tf.strokeColor = 0x965F41;
        return tf;
    };
    LastJiFenTabbar.prototype.clearViews = function () {
        if (this.numChildren == 0)
            return;
        var child = this.getChildAt(0);
        while (child) {
            if (child instanceof HIRTabbarBitmap) {
                this.bgObjs.push(child);
            }
            else if (child instanceof BaseTextField) {
                this.tfObjs.push(child);
            }
            this.removeChild(child);
            if (this.numChildren == 0)
                break;
            child = this.getChildAt(0);
        }
    };
    LastJiFenTabbar.prototype.updateBg = function (bgName, bg) {
        var texture = RES.getRes(bgName);
        bg.texture = texture;
        bg.width = texture.textureWidth;
        bg.height = texture.textureHeight;
        bg.anchorOffsetX = bg.width / 2.0;
    };
    LastJiFenTabbar.prototype.getIndexInArray = function (item, arr) {
        for (var i = 0; i < arr.length; i++) {
            if (arr[i] == item) {
                return i;
            }
        }
        return false;
    };
    return LastJiFenTabbar;
}(egret.DisplayObjectContainer));
__reflect(LastJiFenTabbar.prototype, "LastJiFenTabbar");
var HIRTabbarBitmap = (function (_super) {
    __extends(HIRTabbarBitmap, _super);
    function HIRTabbarBitmap() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.index = 0;
        return _this;
    }
    return HIRTabbarBitmap;
}(egret.Bitmap));
__reflect(HIRTabbarBitmap.prototype, "HIRTabbarBitmap");
var LastJiFenView = (function (_super) {
    __extends(LastJiFenView, _super);
    function LastJiFenView() {
        var _this = _super.call(this) || this;
        _this._personLoading = false;
        _this._bangLoading = false;
        _this.width = GameData.stageW;
        _this.height = GameData.stageH;
        _this.touchEnabled = true;
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.ViewDidLoad, _this);
        return _this;
    }
    LastJiFenView.prototype.ViewDidLoad = function () {
        this.addEventListener(egret.Event.REMOVED_FROM_STAGE, this.viewDidDisappear, this);
        // 赋初值
        this.init();
        // 1.背景幕布
        if (!this.contains(this.bgMask))
            this.addChild(this.bgMask);
        // 2.content
        if (!this.contains(this.contentView))
            this.addChild(this.contentView);
        // 3.背景
        if (!this.contentView.contains(this.bg))
            this.contentView.addChild(this.bg);
        // 4.tabbar
        if (!this.contentView.contains(this.tabbar))
            this.contentView.addChild(this.tabbar);
        // 5.个人积分榜
        if (!this.contentView.contains(this.personTableView))
            this.contentView.addChild(this.personTableView);
        // 6.帮会积分榜
        if (!this.contentView.contains(this.bangTableView))
            this.contentView.addChild(this.bangTableView);
        // 7.下次活动时间
        if (!this.contentView.contains(this.timeLabel))
            this.contentView.addChild(this.timeLabel);
        // 8.关闭按钮
        if (!this.contentView.contains(this.cancelBtn))
            this.contentView.addChild(this.cancelBtn);
        // 9.标题
        if (!this.contentView.contains(this.titleLabel))
            this.contentView.addChild(this.titleLabel);
        // 10.上期时间背景
        if (!this.contentView.contains(this.todayShape))
            this.contentView.addChild(this.todayShape);
        // 11.上期时间
        if (!this.contentView.contains(this.todayLabel))
            this.contentView.addChild(this.todayLabel);
        // 12.空
        if (!this.contentView.contains(this.emptyLabel))
            this.contentView.addChild(this.emptyLabel);
        // 添加动画
        this.addAnimation();
    };
    LastJiFenView.prototype.viewDidDisappear = function () {
        this.removeEventListener(egret.Event.REMOVED_FROM_STAGE, this.viewDidDisappear, this);
        this.personTableView.dataSource = [];
        this.bangTableView.dataSource = [];
        this._personLoading = false;
        this._bangLoading = false;
    };
    /*********************************************** private **********************************************************/
    LastJiFenView.prototype.tabbarChangeAction = function (index) {
        this.bangTableView.visible = index == 1;
        this.personTableView.visible = !this.bangTableView.visible;
        this._currentIndex = index;
        switch (index) {
            case 0:
                this.queryPersonData();
                break;
            case 1:
                this.queryBangData();
                break;
        }
    };
    LastJiFenView.prototype.init = function () {
        this.tabbar.index = 0;
        this.personTableView.visible = this.bangTableView.visible = false;
    };
    LastJiFenView.prototype.cancelAction = function () {
        egret.Tween.removeTweens(this.contentView);
        egret.Tween.get(this.contentView).to({ scaleX: 0, scaleY: 0 }, 100).call(function () {
            if (this.parent)
                this.parent.removeChild(this);
        }.bind(this));
    };
    // 请求个人排行数据
    LastJiFenView.prototype.queryPersonData = function () {
        if (this._personLoading) {
            this.showEmpty(false, 0);
            return;
        }
        this._personLoading = true;
        var self = this;
        //?action=boxlastpersonrank
        CurlUtil.curl(config.api_url + '/bxg/rank/personal/last', {}).then(function (data) {
            if (self._currentIndex != 0) {
                self._personLoading = false;
                return;
            }
            if (data['status'] == "success") {
                data = data['data'];
                // 更新时间显示
                self.updateDate(data['next_time'], data['date']);
                // 刷新tableView数据源
                var dataSource = data['list'] || [];
                if (dataSource.length > 0) {
                    self.personTableView.dataSource = dataSource;
                }
                else {
                    self._personLoading = false;
                }
                // 显示空
                self.showEmpty(dataSource.length == 0, 0);
            }
            else {
                self._personLoading = false;
                self.showEmpty(true, 0);
                self.updateDate('', '');
            }
        }).catch(function (data) {
            self._personLoading = false;
            self.showEmpty(true, 0);
            self.updateDate('', '');
        });
    };
    // 请求帮派数据
    LastJiFenView.prototype.queryBangData = function () {
        if (this._bangLoading) {
            this.showEmpty(false, 1);
            return;
        }
        this._bangLoading = true;
        var self = this;
        //?action=boxlastbangrank 
        CurlUtil.curl(config.api_url + '/bxg/rank/gang/last', {}).then(function (data) {
            if (self._currentIndex != 1) {
                self._bangLoading = false;
                return;
            }
            if (data['status'] == "success") {
                data = data['data'];
                // 更新时间显示
                self.updateDate(data['next_time'], data['date']);
                // 刷新tableView数据源
                var dataSource = data['list'] || [];
                if (dataSource.length > 0) {
                    self.bangTableView.dataSource = dataSource;
                }
                else {
                    self._bangLoading = false;
                }
                self.showEmpty(dataSource.length == 0, 1);
            }
            else {
                self._bangLoading = false;
                self.showEmpty(true, 0);
                self.updateDate('', '');
            }
        }).catch(function (data) {
            self._bangLoading = false;
            self.showEmpty(true, 0);
            self.updateDate('', '');
        });
    };
    // 更新时间
    LastJiFenView.prototype.updateDate = function (next, date) {
        if (next) {
            this.timeLabel.text = "下次活动开启时间\n" + next;
        }
        else {
            this.timeLabel.text = '';
        }
        if (date) {
            this.todayLabel.text = date;
            this.todayShape.visible = true;
            this.titleLabel.y = 122;
        }
        else {
            this.todayLabel.text = '';
            this.todayShape.visible = false;
            this.titleLabel.y = 140;
        }
    };
    // 添加动画
    LastJiFenView.prototype.addAnimation = function () {
        this.contentView.scaleX = this.contentView.scaleY = 0;
        egret.Tween.removeTweens(this.contentView);
        egret.Tween.get(this.contentView).to({ scaleX: 1, scaleY: 1 }, 500, egret.Ease.backOut);
    };
    // 空数据
    LastJiFenView.prototype.showEmpty = function (show, index) {
        this.emptyLabel.visible = show;
        this.personTableView.visible = this.bangTableView.visible = false;
        if (show)
            return;
        switch (index) {
            case 0:
                this.personTableView.visible = true;
                break;
            case 1:
                this.bangTableView.visible = true;
                break;
        }
    };
    Object.defineProperty(LastJiFenView.prototype, "emptyLabel", {
        /*********************************************** getter **********************************************************/
        get: function () {
            if (!this._emptyLabel) {
                var emptyLabel = new EmptyView();
                emptyLabel.width = this.width;
                emptyLabel.y = utils.getMaxY(this.tabbar) + 150;
                emptyLabel.visible = false;
                this._emptyLabel = emptyLabel;
            }
            return this._emptyLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenView.prototype, "todayShape", {
        get: function () {
            if (!this._todayShape) {
                var todayShape = new egret.Shape();
                todayShape.x = this.todayLabel.x;
                todayShape.y = this.todayLabel.y;
                todayShape.width = this.todayLabel.width;
                todayShape.height = this.todayLabel.height;
                todayShape.graphics.beginFill(0x7B490D);
                todayShape.graphics.drawRoundRect(0, 0, todayShape.width, todayShape.height, 20);
                todayShape.graphics.endFill();
                this._todayShape = todayShape;
            }
            return this._todayShape;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenView.prototype, "todayLabel", {
        get: function () {
            if (!this._todayLabel) {
                var todayLabel = new BaseTextField();
                todayLabel.textColor = 0xFFF894;
                todayLabel.text = "";
                todayLabel.width = 188;
                todayLabel.height = 35;
                todayLabel.size = 26;
                todayLabel.textAlign = egret.HorizontalAlign.CENTER;
                todayLabel.verticalAlign = egret.VerticalAlign.MIDDLE;
                todayLabel.x = (this.contentView.width - todayLabel.width) / 2.0;
                todayLabel.y = utils.getMaxY(this.titleLabel) + 10;
                this._todayLabel = todayLabel;
            }
            return this._todayLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenView.prototype, "titleLabel", {
        get: function () {
            if (!this._titleLabel) {
                var titleLabel = new BaseTextField();
                titleLabel.text = "上期奖励分配";
                titleLabel.x = this.bgX;
                titleLabel.width = this.contentView.width - 2 * titleLabel.x;
                titleLabel.y = 122;
                titleLabel.textAlign = egret.HorizontalAlign.CENTER;
                titleLabel.stroke = 4;
                titleLabel.strokeColor = 0xBA7114;
                titleLabel.textColor = 0xF2E019;
                titleLabel.bold = true;
                titleLabel.size = 38;
                this._titleLabel = titleLabel;
            }
            return this._titleLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenView.prototype, "cancelBtn", {
        get: function () {
            if (!this._cancelBtn) {
                var cancelBtn = utils.createBitmapByName("x", { offsetX: 0.5, offsetY: 0.5 });
                cancelBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.cancelAction, this);
                cancelBtn.touchAnimation = true;
                cancelBtn.x = this.contentView.width - 100;
                cancelBtn.y = 165;
                this._cancelBtn = cancelBtn;
            }
            return this._cancelBtn;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenView.prototype, "timeLabel", {
        get: function () {
            if (!this._timeLabel) {
                var timeLabel = new BaseTextField();
                timeLabel.height = 110;
                timeLabel.textAlign = egret.HorizontalAlign.CENTER;
                timeLabel.textColor = 0x7C552C;
                timeLabel.lineSpacing = 10;
                timeLabel.x = this.bgX;
                timeLabel.width = (this.contentView.width - 2 * timeLabel.x);
                timeLabel.y = this.contentView.height - timeLabel.height - 50;
                timeLabel.text = "下次活动开启时间\n";
                timeLabel.verticalAlign = egret.VerticalAlign.MIDDLE;
                timeLabel.size = 26;
                timeLabel.bold = true;
                this._timeLabel = timeLabel;
            }
            return this._timeLabel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenView.prototype, "bangTableView", {
        get: function () {
            if (!this._bangTableView) {
                var bangTableView = new TableView.TableView();
                bangTableView.x = this.bgX + 20;
                bangTableView.width = Math.floor(this.contentView.width - 2 * bangTableView.x);
                bangTableView.y = utils.getMaxY(this.tabbar);
                bangTableView.height = this.timeLabel.y - bangTableView.y;
                bangTableView.visible = false;
                bangTableView.itemRenderer = LastJiFenBangCell;
                LastJiFenBangCell.WIDTH = bangTableView.width;
                this._bangTableView = bangTableView;
            }
            return this._bangTableView;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenView.prototype, "personTableView", {
        get: function () {
            if (!this._personTableView) {
                var personTableView = new TableView.TableView();
                personTableView.x = this.bgX + 20;
                personTableView.width = Math.floor(this.contentView.width - 2 * personTableView.x);
                personTableView.y = utils.getMaxY(this.tabbar);
                personTableView.height = this.timeLabel.y - personTableView.y;
                personTableView.visible = false;
                personTableView.itemRenderer = LastJiFenPersonCell;
                LastJiFenPersonCell.WIDTH = personTableView.width;
                this._personTableView = personTableView;
            }
            return this._personTableView;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenView.prototype, "tabbar", {
        get: function () {
            if (!this._tabbar) {
                var tabbar = new LastJiFenTabbar();
                var items = ["个人积分榜", "帮会积分榜"];
                tabbar.items = items;
                tabbar.callback = this.tabbarChangeAction.bind(this);
                // tabbar.width = this.contentView.width - 2 * this.bgX;
                tabbar.width = 190 * items.length + 20 * (items.length - 1);
                tabbar.height = 80;
                tabbar.x = this.bgX + 20;
                tabbar.y = 230;
                this._tabbar = tabbar;
            }
            return this._tabbar;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenView.prototype, "bgX", {
        get: function () {
            return 56 * this.bg.width / 600 + 10;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenView.prototype, "bg", {
        get: function () {
            if (!this._bg) {
                var bg = utils.createBitmapByName('djc_bg', { width: this.contentView.width });
                bg.scale9Grid = new egret.Rectangle(0, 244, bg.width, 250);
                bg.height = this.contentView.height;
                bg.x = (this.contentView.width - bg.width) / 2.0 + 10;
                bg.y = (this.contentView.height - bg.height) / 2.0;
                this._bg = bg;
            }
            return this._bg;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenView.prototype, "contentView", {
        get: function () {
            if (!this._contentView) {
                var contentView = new egret.DisplayObjectContainer();
                contentView.width = this.width;
                contentView.height = this.height * 0.9;
                contentView.anchorOffsetX = contentView.width / 2.0;
                contentView.anchorOffsetY = contentView.height / 2.0;
                contentView.x = (this.width - contentView.width) / 2.0 + contentView.anchorOffsetX;
                contentView.y = (this.height - contentView.height) / 2.0 + contentView.anchorOffsetY;
                this._contentView = contentView;
            }
            return this._contentView;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LastJiFenView.prototype, "bgMask", {
        get: function () {
            if (!this._bgMask) {
                var bgMask = new egret.Shape();
                bgMask.graphics.beginFill(0x000000, 0.7);
                bgMask.graphics.drawRect(0, 0, GameData.stageW, GameData.stageH);
                bgMask.graphics.endFill();
                this._bgMask = bgMask;
            }
            return this._bgMask;
        },
        enumerable: true,
        configurable: true
    });
    return LastJiFenView;
}(egret.DisplayObjectContainer));
__reflect(LastJiFenView.prototype, "LastJiFenView");
var TopItem = (function (_super) {
    __extends(TopItem, _super);
    function TopItem(data) {
        var _this = _super.call(this) || this;
        _this.itemData = null;
        _this.itemData = data;
        _this.initView();
        _this.anchorOffsetX = _this.width / 2;
        _this.anchorOffsetY = _this.height / 2;
        return _this;
    }
    TopItem.prototype.initView = function () {
        this.width = 160;
        //头像
        var headView = new eui.Image();
        headView.width = this.width;
        headView.height = this.width;
        headView.source = this.itemData.head_url;
        var shape = utils.drawRound(0, 0, this.width, this.width, 0x000, 10);
        this.addChild(shape);
        headView.mask = shape;
        this.addChild(headView);
        //头像边框
        var iconBorder = utils.createBitmapByName("icon_border");
        iconBorder.width = iconBorder.height = headView.width;
        this.addChild(iconBorder);
        var levelLabel = utils.createTextField({
            width: headView.width / 2,
            height: 30,
            x: headView.width / 2,
            y: headView.height - 30,
            stroke: 2,
            strokeColor: 0x644205,
            textColor: 0xFBE43C,
            size: 20,
            italic: true,
            text: 'Lv' + this.itemData.level_no
        });
        this.addChild(levelLabel);
        //昵称与背景
        var name_bg = utils.createBitmapByName('phb_name');
        name_bg.x = this.width / 2 - name_bg.width / 2;
        name_bg.y = headView.height + 60;
        this.addChild(name_bg);
        var name = utils.createTextField({
            width: name_bg.width,
            height: name_bg.height - 10,
            x: name_bg.x,
            y: name_bg.y,
            textColor: 0xFFFFFF,
            text: utils.getChar(this.itemData.nickname, 18)
        });
        this.addChild(name);
        //积分
        var jf_box = utils.createSprite({
            width: this.width * 1.1,
            height: name_bg.height * 0.8,
            y: name_bg.y + name_bg.height + 10,
            x: -this.width * 0.05
        });
        jf_box.graphics.beginFill(0x42251a);
        jf_box.graphics.lineStyle(2, 0x9D6425);
        jf_box.graphics.drawRoundRect(0, 0, jf_box.width, jf_box.height, 70, 70);
        jf_box.graphics.endFill();
        this.addChild(jf_box);
        var jf = utils.createTextField({
            text: '积分:',
            textColor: 0xedc05d,
            height: jf_box.height,
            x: 10
        });
        jf_box.addChild(jf);
        var jf_num = utils.createTextField({
            width: jf_box.width - jf.width - 10,
            x: jf.width + jf.x,
            height: jf_box.height,
            textColor: 0xFBBB11,
            text: this.itemData.total_score + '',
            bold: true
        });
        jf_box.addChild(jf_num);
    };
    return TopItem;
}(egret.DisplayObjectContainer));
__reflect(TopItem.prototype, "TopItem");
/**
 * 前3排行榜
 */
var TopThreeView = (function (_super) {
    __extends(TopThreeView, _super);
    function TopThreeView(data) {
        var _this = _super.call(this) || this;
        _this.contentView = null;
        _this.topData = null;
        _this.topData = data;
        if (!Array.isArray(_this.topData) || _this.topData.length <= 0) {
            Toast.makeText({ text: '排行榜数据异常！' }).show();
            _this.removeSelf();
            return _this;
        }
        _this.initView();
        _this.touchEnabled = true;
        _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.addToStage, _this);
        return _this;
    }
    TopThreeView.prototype.addToStage = function () {
        this.addAnimation();
    };
    TopThreeView.prototype.initView = function () {
        this.width = GameData.stageW;
        this.height = GameData.stageH;
        //遮罩
        this.graphics.beginFill(0x000000, 0.7);
        this.graphics.drawRect(0, 0, this.width, this.height);
        this.graphics.endFill();
        //背景
        var bg = utils.createBitmapByName('ph_bg');
        var box = utils.createSprite({
            width: bg.width,
            height: bg.height,
            offsetX: 0.5,
            offsetY: 0.5,
            x: this.width / 2,
            y: this.height / 2
        });
        this.contentView = box;
        this.addChild(box);
        box.addChild(bg);
        var len = this.topData.length;
        if (len > 0) {
            var top1 = new TopItem(this.topData[0]);
            top1.x = box.width / 2;
            top1.y = box.height / 2 + 50;
            box.addChild(top1);
            var f = utils.createBitmapByName('icon_1', { offsetX: 0.5, offsetY: 0.5 });
            f.x = top1.x - top1.width / 2 + 10;
            f.y = top1.y - top1.height / 2 + 10;
            box.addChild(f);
        }
        if (len > 1) {
            var top2 = new TopItem(this.topData[1]);
            top2.scaleX = top2.scaleY = 0.88;
            top2.x = 150;
            top2.y = 530;
            box.addChild(top2);
            var s = utils.createBitmapByName('icon_2', { offsetX: 0.5, offsetY: 0.5 });
            s.x = top2.x - top2.width / 2 * 0.88 + 10;
            s.y = top2.y - top2.height / 2 * 0.88 + 10;
            box.addChild(s);
        }
        if (len > 2) {
            var top3 = new TopItem(this.topData[2]);
            top3.scaleX = top3.scaleY = 0.8;
            top3.x = 580;
            top3.y = 580;
            box.addChild(top3);
            var t = utils.createBitmapByName('icon_3', { offsetX: 0.5, offsetY: 0.5 });
            t.x = top3.x - top3.width / 2 * 0.8 + 10;
            t.y = top3.y - top3.height / 2 * 0.8 + 10;
            box.addChild(t);
        }
        var btn = utils.createBitmapByName('x', {
            offsetX: 0.5,
            offsetY: 0.5
        });
        btn.touchAnimation = true;
        btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.removeSelf, this);
        btn.x = box.width - btn.width / 2;
        btn.y = 130;
        box.addChild(btn);
    };
    TopThreeView.prototype.removeSelf = function () {
        Main.removeTop3View();
    };
    // 添加动画
    TopThreeView.prototype.addAnimation = function () {
        this.contentView.scaleX = 0.1;
        this.contentView.scaleY = 0.1;
        egret.Tween.removeTweens(this.contentView);
        egret.Tween.get(this.contentView).to({ scaleX: 1, scaleY: 1 }, 500, egret.Ease.backOut);
    };
    return TopThreeView;
}(egret.Sprite));
__reflect(TopThreeView.prototype, "TopThreeView");
;window.Main = Main;